Skip to content
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

LLVMgold.dll is not found on android-ndk-r13b-windows #251

Closed
Klayflash opened this issue Nov 28, 2016 · 9 comments
Closed

LLVMgold.dll is not found on android-ndk-r13b-windows #251

Klayflash opened this issue Nov 28, 2016 · 9 comments
Assignees
Labels
Milestone

Comments

@Klayflash
Copy link

Klayflash commented Nov 28, 2016

I'm attempting to add -flto for link-time optimization. Link fails with error:

LLVMgold.so: could not load plugin library: unable to load dll

*LLVMgold*.* file is absent in android-ndk-r13b-windows.

How can I use link time optimization on Windows?

NDK API level: 23
Compiler and linker: clang.exe

See also
#108

@DanAlbert
Copy link
Member

Dup of #108

@Klayflash
Copy link
Author

Please clarify. Is this issue has been fixed in android-ndk-r13b-windows ?

@DanAlbert
Copy link
Member

No. Not fixed.

@Klayflash
Copy link
Author

Will fix be available in next after android-ndk-r13b-windows?

@DanAlbert DanAlbert added this to the unplanned milestone Nov 29, 2016
@DanAlbert
Copy link
Member

DanAlbert commented Nov 29, 2016

I'm going to reopen this so we can track Darwin and Windows separately, since they're probably not going to get fixed at the same time.

The short answer here is that this probably isn't going to be supported any time soon. Clang's LTO support currently only works on Linux. Darwin support seems to be nearly there, but I don't know if anyone has ever looked at Windows. We'll get it up and running on Darwin first since there's more demand for that (and it's likely the easier task as well since it's at least unix-like), but after that we can look at what it will take to support Windows.

@DanAlbert DanAlbert reopened this Nov 29, 2016
@Klayflash
Copy link
Author

This (https://www.crystax.net/en/android/ndk) lib contains LLVMgold.dll.
May be LLVMgold.dll is built because cross-build is used:

WARNING!!! Building the Windows version of CrystaX NDK is only supported on a Linux host (cross-build used). Building on a Windows host is not tested and not supported.

I hope this info will help to you. Thank you for a job.

@Klayflash
Copy link
Author

I have built LLVMgold.dll on windows platform! It was not easy...

The batch file that I used to build LLVMgold.dll:

@echo off
rem download cmake tool and unpack into next line folder
set PATH=%PATH%;C:\temp\Buildgold\cmake-3.7.1-win64-x64\bin
rem download "LLVM source code" from http://llvm.org/releases/download.html#3.9.0 and unpack into next line folder
cd C:\temp\Buildgold\llvm-3.8.1.src
rem modify llvm-3.8.1.src\cmake\modules\HandleLLVMOptions.cmake: set LLVM_ENABLE_PLUGINS to ON
mkdir mybuilddir
cd mybuilddir
rem cmake 3.7.1 was used
cmake --version
IF ERRORLEVEL 1 goto error
cmake .. -G "Visual Studio 14 2015 Win64" -DPYTHON_EXECUTABLE=C:\lib\android\1\android-ndk-r13b-windows-x86_64\android-ndk-r13b\prebuilt\windows-x86_64\bin\python.exe -DLLVM_BINUTILS_INCDIR=C:\temp\Buildgold\binutils\include -DCMAKE_BUILD_TYPE=Release
IF ERRORLEVEL 1 goto error
cmake --build . --config Release --target LLVMgold
IF ERRORLEVEL 1 goto error
:success
echo "SUCCESS"
goto exit
:error
echo "ERROR!"
goto exit
:exit
pause

Steps:

  1. I added "-flto" to clang compiler and same for clang linker.
  2. run build. After build, expected error "could not load plugin library" is shown:
C:\lib\android\2\android-ndk-r14-beta1-windows-x86_64\android-ndk-r14-beta1\toolchains\x86-4.9\prebuilt\windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:\lib\android\2\android-ndk-r14-beta1-windows-x86_64\android-ndk-r14-beta1\toolchains\llvm\prebuilt\windows-x86_64\bin/../lib64/LLVMgold.so: could not load plugin library: unable to load dll
C:\lib\android\2\android-ndk-r14-beta1-windows-x86_64\android-ndk-r14-beta1\toolchains\x86-4.9\prebuilt\windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:\temp\myBuildDir\results\80_default.o:1:3: invalid character
C:\lib\android\2\android-ndk-r14-beta1-windows-x86_64\android-ndk-r14-beta1\toolchains\x86-4.9\prebuilt\windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:\temp\myBuildDir\results\80_default.o:1:3: syntax error, unexpected $end

  1. I added to folder this dll and rename, so full path is C:\lib\android\2\android-ndk-r14-beta1-windows-x86_64\android-ndk-r14-beta1\toolchains\llvm\prebuilt\windows-x86_64\lib64\LLVMgold.so
  2. run build. After build, unexpected error "1:3: invalid character" is shown:
C:\lib\android\2\android-ndk-r14-beta1-windows-x86_64\android-ndk-r14-beta1\toolchains\x86-4.9\prebuilt\windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:\temp\myBuildDir\results\80_default.o:1:3: invalid character
C:\lib\android\2\android-ndk-r14-beta1-windows-x86_64\android-ndk-r14-beta1\toolchains\x86-4.9\prebuilt\windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:\temp\myBuildDir\results\80_default.o:1:3: syntax error, unexpected $end
C:\lib\android\2\android-ndk-r14-beta1-windows-x86_64\android-ndk-r14-beta1\toolchains\x86-4.9\prebuilt\windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:\temp\myBuildDir\results\80_default.o: not an object or archive
C:\lib\android\2\android-ndk-r14-beta1-windows-x86_64\android-ndk-r14-beta1\toolchains\x86-4.9\prebuilt\windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: C:\temp\myBuildDir\results\28_default.o:1:3: invalid character

Why unexpected error is shown?

@stephenhines
Copy link
Collaborator

I don't think it is safe to build LLVMgold.dll from the 3.9 sources, since the Clang/LLVM it is linking against is most definitely not 3.9. It is likely that there are missing symbols or other incompatibilities here, so you will have to wait until we can rebuild the compiler with further patches to get the appropriate .dll file.

miodragdinic pushed a commit to MIPS/ndk that referenced this issue Apr 17, 2018
This actually does work for GCC.

Test: ./run_tests.py --rebuild --filter flto  # on windows
Bug: android/ndk#251
Change-Id: Ieea8a5abdf0ede6561450ed785063118523c03a7
@DanAlbert
Copy link
Member

LLVMgold.dll landed a few releases ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants