-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[emmake]compile OpenBLAS using emmake #3640
Comments
You have to use GNU make, or alternatively cmake e.g. |
What is your cpu architecture ? The error comes about because your compiler apparently does not define one of the usual architecture macros like |
From https://github.com/nemequ/pre-defined-macros/blob/master/c/emcc/Linux-x86_64-1.37.9.h the Emscripten emcc appears to define
next copy cpuid_sparc.c to cpuid_asmjs.c and edit the new file:
|
And probably |
So I had another quick look at this - the initial messages about getarch.c are misleading, as this is basically a cross-compilation anyway, so no need to actually autodetect platform details and in particular no need to compile getarch itself to webasm. Also, A quick hack would be to add the following lines at the end of ctest.c
then in file common.h, around line 387 add this:
and in Makefile.rule, uncomment the line that has With these changes, |
@924657644 any chance you could test this, or at least suggest a test for the generated webassembly file ? Otherwise I intend to close this. (I noticed there is also https://github.com/likr/emlapack , an emscripten port of an old version of the unoptimized reference BLAS/LAPACK implementation) |
I tried to build openblas with emscripten as @martin-frbg proposed above, but then I got the following crash when generating the final Traceback (most recent call last):
File "/io/code/emsdk-linux/upstream/emscripten/emcc.py", line 4147, in <module>
sys.exit(main(sys.argv))
File "/usr/lib/python3.8/contextlib.py", line 75, in inner
return func(*args, **kwds)
File "/io/code/emsdk-linux/upstream/emscripten/emcc.py", line 4140, in main
ret = run(args)
File "/io/code/emsdk-linux/upstream/emscripten/emcc.py", line 1208, in run
phase_calculate_system_libraries(state, linker_arguments, linker_inputs, newargs)
File "/usr/lib/python3.8/contextlib.py", line 75, in inner
return func(*args, **kwds)
File "/io/code/emsdk-linux/upstream/emscripten/emcc.py", line 2862, in phase_calculate_system_libraries
extra_files_to_link += system_libs.calculate(all_linker_inputs, newargs, forced=state.forced_stdlibs)
File "/io/code/emsdk-linux/upstream/emscripten/tools/system_libs.py", line 1958, in calculate
handle_reverse_deps(input_files)
File "/io/code/emsdk-linux/upstream/emscripten/tools/system_libs.py", line 1792, in handle_reverse_deps
symbolses = building.llvm_nm_multiple([os.path.abspath(t) for t in input_files])
File "/usr/lib/python3.8/contextlib.py", line 75, in inner
return func(*args, **kwds)
File "/io/code/emsdk-linux/upstream/emscripten/tools/building.py", line 185, in llvm_nm_multiple
for key, value in parse_llvm_nm_symbols(results.stdout).items():
File "/io/code/emsdk-linux/upstream/emscripten/tools/building.py", line 581, in parse_llvm_nm_symbols
status = line[entry_pos + 11] # Skip address, which is always fixed-length 8 chars.
IndexError: string index out of range I edited
so the |
If I replace the |
This may have been broken by some commits in the meantime, or you may be using a different version of emscripten ? Not sure where the "signature mismatch" for caxpy comes from, certainly don't remember getting it in my test build back in september. |
@ogrisel I had a similar error with emscripten 3.1.24 but somehow it seems to work without error in 3.1.27 (latest released version). For clarity, here is how I am building for wasm (copying an pasting the relevant instructions from #3640 (comment)):
diff --git a/Makefile.rule b/Makefile.rule
index 5e6cefc2..c18ea288 100644
--- a/Makefile.rule
+++ b/Makefile.rule
@@ -231,7 +231,7 @@ NO_AFFINITY = 1
# Common Optimization Flag;
# The default -O2 is enough.
# Flags for POWER8 are defined in Makefile.power. Don't modify COMMON_OPT
-# COMMON_OPT = -O2
+COMMON_OPT = -O2 -Wno-implicit-function-declaration
# gfortran option for LAPACK to improve thread-safety
# It is enabled by default in Makefile.system for gfortran
For completeness sake, I was not getting a traceback with 3.1.24 but an error saying
Excerpt from the make output:
Maybe (close to random guess) this is the fix from emscripten-core/emscripten#18152. |
So supposedly the emcc fix was merged as emscripten-core/emscripten@cba63c7 so included in |
Not a # need to git clone only the first time
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk ./emsdk install latest
./emsdk activate latest
source emsdk_env.sh
|
I am pretty sure I did exactly the same... |
Well, the version of emscripten I tried it with has |
That's f2c converting all SUBROUTINEs to functions that return int. I'm preparing a PR |
I am seeing some warnings like this when building OpenBLAS, is that related to what you are saying?
If that's the case that would be very nice, because these warnings turn into errors when I am trying to link scipy to OpenBLAS in Pyodide, see pyodide/pyodide#3331 (comment) |
Yes, that is exactly it. When I tested the compilation with emscripten back in september, I only tried with the BLAS parts of OpenBLAS and not the LAPACK. |
This is unfortunately taking a lot longer than I had anticipated - I hope to have the PR ready sometime tomorrow. |
OK sounds great, thanks a lot! |
@martin-frbg thanks a lot for your PR #3861, I still see some signature mismatch warnings when compiling the same way as #3861 (comment)? Maybe these warnings are not that important? Some of them have
Here is the log with all the signature mismatch warnings: |
I saw them too, but I think they are "only" from missing or outdated declarations within the test/ctest/utest sources. At least they do not block building of the library - I still plan to get to them "later". |
OK makes sense, thanks a lot! |
I am trying to make openblas work for emscriptem on vcpkg. I am currently hitting some errors:
And I am not sure how to fix them. I previously tried using EDIT: Maybe I should make more explicit that I think it would be ideal to have a dedicated WASM target, which would configure everything just like other targets |
DTB_DEFAULT_ENTRIES should get defined automatically when setting the RISCV64_TARGET - at least when using the Makefile build |
I tried to compile OpenBLAS using emmake, but I had the following problems:
Is there any other way I can solve the problem? I want to compile the.c file that contains the OpenBLas function as the.wasm file
The text was updated successfully, but these errors were encountered: