Closed xlla closed 3 years ago
Try using the prebuilt LLVM on this repo. I have used them before to build the toolchain and haven't encountered any problems.
FWIW, I've got an inofficial build for aarch64 ubuntu, at https://martin.st/temp/llvm-mingw-20201020-ucrt-ubuntu-18.04-aarch64.tar.xz.
I am try build on aarch64 host, with a pre-build clang (llvm) on another x86_64 host, because it is so huge and lag to be built on device.
So, this is a setup that isn't entirely supported - it's possible, but there's no premade scripts for this setup. See #59 for a discussion on how to do this.
clang 10.0.1 (llvm) was install to /usr/bin and /usr/lib and /lib. It is differ to version defined in build-llvm.sh.
PREFIX=build I have link "/usr/bin, /usr/lib /usr/include" to $PREFIX/, to emulate result of build-llvm.sh. then skip the first script, and manual prepare all related llvm source,
Don't symlink /usr/include anywhere, please see that other issue with descriptions of what you need to do. Really try to replicate the proper install in detail, or things may misbehave vaguely.
./build-llvm.sh $PREFIX following script was executed successful.
./install-wrappers.sh $PREFIX ./build-mingw-w64.sh $PREFIX ./build-mingw-w64-tools.sh $PREFIX ./build-compiler-rt.sh $PREFIX ./build-mingw-w64-libraries.sh $PREFIX but stuck in this one
rpi4:~/git/llvm-mingw$ ./build-libcxx.sh build libunwind... share [TRUE] static [FALSE] enter build-i686-shared CMake Error at src/CMakeLists.txt:86 (message): Compiler doesn't support generation of unwind tables if exception support is disabled. Building libunwind DSO with runtime dependency on C++ ABI library is not supported.
-- Configuring incomplete, errors occurred! See also "/home/pi/git/llvm-mingw/llvm-project/libunwind/build-i686-shared/CMakeFiles/CMakeOutput.log". See also "/home/pi/git/llvm-mingw/llvm-project/libunwind/build-i686-shared/CMakeFiles/CMakeError.log". errors inside CMakeError.log is
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. Compiler: /home/pi/git/llvm-mingw/build/bin/i686-w64-mingw32-clang Build flags: -Wno-dll-attribute-on-redeclaration Id flags:
The output was: 1 lld: error: unable to find library -lgcc_s lld: error: unable to find library -lgcc_s clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /home/pi/git/llvm-mingw/build/bin/i686-w64-mingw32-clang++ Build flags: -Wno-dll-attribute-on-redeclaration Id flags:
The output was: 1 lld: error: unable to find library -lc++ lld: error: unable to find library -lgcc_s lld: error: unable to find library -lgcc_s clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
... [2/2] Linking C executable cmTC_cab64.exe FAILED: cmTC_cab64.exe : && /home/pi/git/llvm-mingw/build/bin/i686-w64-mingw32-clang -Wno-dll-attribute-on-redeclaration -v CMakeFiles/cmTC_cab64.dir/CMakeCCompilerABI.c.obj -o cmTC_cab64.exe -Wl,--out-implib,libcmTC_cab64.dll.a -Wl,--major-image-version,0,--minor-image-version,0 && : clang version 10.0.1 (https://github.com/llvm/llvm-project ef32c611aa214dea855364efd7ba451ec5ec3f74) Target: i686-w64-windows-gnu Thread model: posix InstalledDir: /home/pi/git/llvm-mingw/build/bin "/home/pi/git/llvm-mingw/build/bin/ld.lld" -m i386pe -Bdynamic -o cmTC_cab64.exe /home/pi/git/llvm-mingw/build/i686-w64-mingw32/lib/crt2.o /home/pi/git/llvm-mingw/build/i686-w64-mingw32/lib/crtbegin.o -L/home/pi/git/llvm-mingw/build/i686-w64-mingw32/lib -L/home/pi/git/llvm-mingw/build/lib -L/home/pi/git/llvm-mingw/build/i686-w64-mingw32/sys-root/mingw/lib CMakeFiles/cmTC_cab64.dir/CMakeCCompilerABI.c.obj --out-implib libcmTC_cab64.dll.a --major-image-version 0 --minor-image-version 0 -lmingw32 /usr/lib/clang/10.0.1/lib/windows/libclang_rt.builtins-i386.a -lgcc_s -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 /usr/lib/clang/10.0.1/lib/windows/libclang_rt.builtins-i386.a -lgcc_s -lmoldname -lmingwex -lmsvcrt /home/pi/git/llvm-mingw/build/i686-w64-mingw32/lib/crtend.o lld: error: unable to find library -lgcc_s
So, this really shouldn't be using a libgcc_s anywhere. If you have a working setup on x86_64, you should be able to see that there's no libgcc_s there, so you shouldn't be using one.
I won't comment on the rest of the setup that is about trying to fix things up to use libgcc_s.a, because you shouldn't be using it. You need to debug what goes wrong in libunwind's cmake files when it ends up trying to use libgcc_s when it really shouldn't be doing that.
but failure compile using $ARCH-w64-mingw32-clang++
rpi4:~/test$ /home/pi/git/llvm-mingw/build/bin/i686-w64-mingw32-clang++ -v junk.cpp -o junk -fuse-ld=/usr/bin/ld.lld lld: error: unable to find library -lc++ clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
You can't use the
Try using the prebuilt LLVM on this repo. I have used them before to build the toolchain and haven't encountered any problems.
Hi @longnguyen2004 , which version the prebuilt LLVM do you use?
@mstorsjo , many thanks for your advice. Now I am confident the pre-build llvm would work for this project after read #59 . I link include folder to simply resolve some missing header file issues.
To emulate build-llvm.sh 's behavior, I fully copy the llvm-project folder from another host (at first, to save space, I only copy [tools libunwind libcxx libcxxabi compiler-rt]), and run build-llvm.sh $PREFIX, interrupt it while ninjia begin compile.
To investigate failure reason, I manually execute the command of build-libcxx.sh, I found if I forgot execute
export PATH="$PREFIX/bin:$PATH"
cmake error will occur, so I add some echo command to trace the PATH variable.
export PATH="$PREFIX/bin:$PATH" echo "current path $PATH" ... echo "libunwind... share [$SHARED] static [$STATIC]" cd libunwind echo "current path $PATH" for arch in $ARCHS; do
then the error was disappeared,
[0/1] Install the project... -- Install configuration: "Release" -- Installing: /home/pi/git/llvm-mingw/build/aarch64-w64-mingw32/lib/libunwind.dll.a libcxx... ... -- Build files have been written to: /home/pi/git/llvm-mingw/llvm-project/libcxx/build-i686-shared ninja: error: unknown target 'generate-cxx-headers'
it now stuck at libcxx.
-- Build files have been written to: /home/pi/git/llvm-mingw/llvm-project/libcxx/build-i686-shared ninja: error: unknown target 'generate-cxx-headers' it now stuck at libcxx.
This sounds like you have an older version of llvm-project, than the 11.0 (or main branch) that these build scripts work with.
If you just want to use it, I'd recommend the build from https://martin.st/temp/llvm-mingw-20201020-ucrt-ubuntu-18.04-aarch64.tar.xz - maybe I'll have to consider making such official builds too.
If you just want to use it, I'd recommend the build from https://martin.st/temp/llvm-mingw-20201020-ucrt-ubuntu-18.04-aarch64.tar.xz - maybe I'll have to consider making such official builds too.
I'v download and test them, it seems work.
rpi4:~/test$ ~/git/llvm-mingw-pre-20201020/bin/aarch64-w64-mingw32-clang++ junk.cpp -o junk rpi4:~/test$ file junk junk: PE32+ executable (console) Aarch64, for MS Windows rpi4:~/test$ ~/git/llvm-mingw-pre-20201020/bin/x86_64-w64-mingw32-clang++ junk.cpp -o junk rpi4:~/test$ file junk junk: PE32+ executable (console) x86-64, for MS Windows rpi4:~/test$ ~/git/llvm-mingw-pre-20201020/bin/armv7-w64-mingw32-clang++ junk.cpp -o junk rpi4:~/test$ file junk junk: PE32 executable (console) ARMv7 Thumb, for MS Windows rpi4:~/test$ ~/git/llvm-mingw-pre-20201020/bin/i686-w64-mingw32-clang++ junk.cpp -o junk rpi4:~/test$ file junk junk: PE32 executable (console) Intel 80386, for MS Windows rpi4:~/test$ ~/git/llvm-mingw-pre-20201020/bin/i686-w64-mingw32-clang++ -v clang version 11.0.0 (https://github.com/llvm/llvm-project.git 176249bd6732a8044d457092ed932768724a6f06) Target: i686-w64-windows-gnu Thread model: posix InstalledDir: /home/pi/git/llvm-mingw-pre-20201020/bin
So, this really shouldn't be using a libgcc_s anywhere. If you have a working setup on x86_64, you should be able to see that there's no libgcc_s there, so you shouldn't be using one.
I'v remove /usr/bin,/usr/lib and /usr/include from $PREFIX, and create only required link as #58 instruction, then redo each script with CLEAN=1 build-xxx.sh, it stuck on sub-lib winstorecompat again while running build-mingw-w64-libraries.sh , in config.log,
./build-i686/config.log:lld: error: unable to find library -lgcc_s
In this round, I don't link libgcc_xxx.a under mingw-w64/mingw-w64-libraries/winpthreads/build-$ARCH/fakelib to $PREFIX/$ARCH-w64-mingw32/lib
I observed that sub-lib winpthreads missing that library too, but it compiles a fake one and depend on it.
winpthreads/build-aarch64/config.log:lld: error: unable to find library -lgcc_s winpthreads/build-aarch64/Makefile:fakelib_libgcc_s_a_AR = $(AR) $(ARFLAGS) winpthreads/build-aarch64/Makefile:EXTRA_libwinpthread_la_DEPENDENCIES = fakelib/libgcc.a fakelib/libgcc_eh.a fakelib/libgcc_s.a
This sounds like you have an older version of llvm-project, than the 11.0 (or main branch) that these build scripts work with.
I think so, I'v change task name to "cxx-headers cxx_abi_headers install-cxx-headers", and change libcxxabi include path to "-DLIBCXXABI_LIBCXX_INCLUDES=$PREFIX/$arch-w64-mingw32/include/c++/v1", and libcxxabi was built.
After link build-$arch/fakelib/libgcc*.a to $PREFIEX/$arch-w64-mingw32/lib, all remain scripts run fine.
I don't know the side effect of remain those fake lib.
I'v run test using llvm-mingw-20201020-ucrt-ubuntu-18.04-aarch64, it seems missing i686-w64-mingw32-widl
rpi4:~/git/llvm-mingw$ ./run-tests.sh ~/git/llvm-mingw-pre-20201020 + '[' 1 -lt 1 ']' + PREFIX=/home/pi/git/llvm-mingw-pre-20201020 ++ cd /home/pi/git/llvm-mingw-pre-20201020 ... + i686-w64-mingw32-widl idltest.idl -h -o i686/idltest.h ./run-tests.sh: line 157: i686-w64-mingw32-widl: command not found
I'v run test on my built, it is lack omp.h at first.
rpi4:~/git/llvm-mingw$ ./run-tests.sh build + '[' 1 -lt 1 ']' + PREFIX=build ... + i686-w64-mingw32-clang hello-omp.c -o i686/hello-omp.exe -fopenmp=libomp hello-omp.c:20:10: fatal error: 'omp.h' file not found #include^~~~~~~ 1 error generated.
after install uasm and run build-openmp.sh, it stuck on lld-link errors
rpi4:~/git/llvm-mingw$ ./run-tests.sh build + '[' 1 -lt 1 ']' + PREFIX=build ... + for test in $TESTS_OMP + case $arch in + i686-w64-mingw32-clang hello-omp.c -o i686/hello-omp.exe -fopenmp=libomp lld-link: error: undefined symbol: ___kmpc_fork_call >>> referenced by /tmp/hello-omp-f78ad1.o:(_main) lld-link: error: undefined symbol: _omp_get_thread_num >>> referenced by /tmp/hello-omp-f78ad1.o:(_.omp_outlined.) lld-link: error: undefined symbol: _omp_get_num_threads >>> referenced by /tmp/hello-omp-f78ad1.o:(_.omp_outlined.) clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
If comment out openmp test, all exe file was generated and stuck on wine error, it is just my goal to build this project 🥇 , I will try to build wine using my built and re-run test later
+ wine hello.exe 009c:err:plugplay:try_add_device Building report descriptor failed, removing device 0068:err:virtual:virtual_setup_exception stack overflow 1376 bytes in thread 0068 addr 0x7bc4b904 stack 0x120aa0 (0x120000-0x121000-0x220000) 009c:err:plugplay:try_add_device Building report descriptor failed, removing device 0024:err:process:exec_process L"Z:\\home\\pi\\git\\llvm-mingw\\test\\i686\\hello.exe" not supported on this system
I'v run test using llvm-mingw-20201020-ucrt-ubuntu-18.04-aarch64, it seems missing i686-w64-mingw32-widl
Yes, that build is missing the *-widl tools; the widl tool had an issue where it failed to build on aarch64 with gcc (the system compiler in ubuntu), this is fixed upstream in mingw-w64 so it won't be an issue in the future.
I'v run test on my built, it is lack omp.h at first.
rpi4:~/git/llvm-mingw$ ./run-tests.sh build
- '[' 1 -lt 1 ']'
- PREFIX=build
...
- i686-w64-mingw32-clang hello-omp.c -o i686/hello-omp.exe -fopenmp=libomp hello-omp.c:20:10: fatal error: 'omp.h' file not found
include
^~~~~~~
1 error generated. after install uasm and run build-openmp.sh, it stuck on lld-link errors
rpi4:~/git/llvm-mingw$ ./run-tests.sh build
'[' 1 -lt 1 ']'
PREFIX=build ...
for test in $TESTS_OMP
case $arch in
i686-w64-mingw32-clang hello-omp.c -o i686/hello-omp.exe -fopenmp=libomp lld-link: error: undefined symbol: ___kmpc_fork_call
referenced by /tmp/hello-omp-f78ad1.o:(_main)
Hmm, I think this might be some detail that was fixed in Clang 11, so if you have an older version it doesn't work.
If comment out openmp test, all exe file was generated and stuck on wine error, it is just my goal to build this project 🥇 , I will try to build wine using my built and re-run test later
- wine hello.exe 009c:err:plugplay:try_add_device Building report descriptor failed, removing device 0068:err:virtual:virtual_setup_exception stack overflow 1376 bytes in thread 0068 addr 0x7bc4b904 stack 0x120aa0 (0x120000-0x121000-0x220000) 009c:err:plugplay:try_add_device Building report descriptor failed, removing device 0024:err:process:exec_process L"Z:\home\pi\git\llvm-mingw\test\i686\hello.exe" not supported on this system
Yeah, the script by default assumes you're on x86, where you can run i686 and x86_64 binaries with wine, but only compile but not run the arm binaries - it probably needs a bit of tweaking when running on aarch64. In particular if you're running on WSL, you don't want to be executing test binaries with wine, you want to run them without any wrapper.
(Wine on aarch64 is a bit tricky, due to https://bugs.winehq.org/show_bug.cgi?id=38780 it doesn't really work with current upstream versions unless you patch it. The recently released Wine 6.0 can, in some build configurations, mostly work without extra patches though...)
Yes, that build is missing the *-widl tools; the widl tool had an issue where it failed to build on aarch64 with gcc (the system compiler in ubuntu), this is fixed upstream in mingw-w64 so it won't be an issue in the future.
after read the discussion in #16 , the omp test is pass too.
+ for test in $TESTS_OMP + case $arch in + i686-w64-mingw32-clang hello-omp.c -o i686/hello-omp.exe -fopenmp=libomp + TESTS_EXTRA=' crt-test-no-builtin crt-test-ansi-stdio hello-exception hello-exception-opt exception-locale exception-locale-opt exception-reduced exception-reduced-opt hello-exception-static tlstest-main uwp-error-mingw32 ubsan hello-omp' + DLL='autoimport-lib tlstest-lib' + compiler_rt_arch=i686 + '[' i686 = i686 ']' + compiler_rt_arch=i386
Wine on aarch64 is a bit tricky
my host is aarch64 , the script's assumes is partially right I need wine to run test . I have built an aarch64 version wine, it can launch aarch64 format win app generated by llvm-mingw.
rpi4:~/winapp$ uname -m aarch64 rpi4:~/winapp$ ~/git/llvm-mingw/build/bin/aarch64-w64-mingw32-clang test-clang.c -o test-clang-aarch64.exe rpi4:~/winapp$ file test-clang-aarch64.exe test-clang-aarch64.exe: PE32+ executable (console) Aarch64, for MS Windows rpi4:~/winapp$ wine64 test-clang-aarch64.exe hello world
to run x86_64 and i686 app, I need llvm-mingw
my host is aarch64 , the script's assumes is partially right I need wine to run test . I have built an aarch64 version wine, it can launch aarch64 format win app generated by llvm-mingw.
rpi4:~/winapp$ uname -m aarch64 rpi4:~/winapp$ ~/git/llvm-mingw/build/bin/aarch64-w64-mingw32-clang test-clang.c -o test-clang-aarch64.exe rpi4:~/winapp$ file test-clang-aarch64.exe test-clang-aarch64.exe: PE32+ executable (console) Aarch64, for MS Windows rpi4:~/winapp$ wine64 test-clang-aarch64.exe hello world
to run x86_64 and i686 app, I need llvm-mingw
You can't run x86 windows apps on aarch64 linux - llvm-mingw won't help with that, and wine doesn't either. It might work with some combination of wine and qemu though, maybe...
You can't run x86 windows apps on aarch64 linux - llvm-mingw won't help with that, and wine doesn't either. It might work with some combination of wine and qemu though, maybe...
Yes, but llvm-mingw can make wine happy to create x86(64) dll on aarch64 host.
While try compiling hangover on aarch64 using llvm-mingw, I am stuck on dlls32, it use winegcc which will call i686-w64-mingw32-gcc to build 32bit x86 dlls for wine-guest32.
please refer hangover/issues/107
I don't know if this is issue on llvm-mingw or on hangover or on llvm upstream.
Closing, unclear what the actionable bug is.
I am try build on aarch64 host, with a pre-build clang (llvm) on another x86_64 host, because it is so huge and lag to be built on device.
clang 10.0.1 (llvm) was install to /usr/bin and /usr/lib and /lib. It is differ to version defined in build-llvm.sh.
PREFIX=build I have link "/usr/bin, /usr/lib /usr/include" to $PREFIX/, to emulate result of build-llvm.sh. then skip the first script, and manual prepare all related llvm source,
following script was executed successful.
but stuck in this one
errors inside CMakeError.log is
I have found libgcc_s.a under mingw-w64/mingw-w64-libraries/winpthreads/build-$ARCH/fakelib so create a link to $PREFIX/$ARCH-w64-mingw32/lib, but still failure.
I wrote a test cpp file and compile use clang++, no errors.
but failure compile using $ARCH-w64-mingw32-clang++