+
Skip to content

Windows lld hangs when multi-threading is enabled #855

@darkspace

Description

@darkspace

In both NDK r18b and r19 beta1 for Windows 64-bit, ld.lld.exe will hang most of the time when linking our project (1078 source files). Possibly it's the same bug reported here:

https://bugs.llvm.org/show_bug.cgi?id=34806

Disabling threads prevents the hang but we would like multi-threading as link times are slow with our project without it. A snippet of CMakeLists.txt to workaround the hang and another unrelated issue with fix-cortex-a8:

set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld -Wl,--no-threads")

string(REPLACE "-Wl,--fix-cortex-a8" "" CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS})
string(REPLACE "-Wl,--fix-cortex-a8" "" CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS})
string(REPLACE "-Wl,--fix-cortex-a8" "" CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})

I downloaded and compiled the latest lld and it does not hang however is also does not appear to be multithreaded even after removing the --no-threads flag, as CPU usage remains at 25% on my quad-core during the link stage. Explicitly setting the --threads flag to lld didn't help. However it's possible I didn't compile it correctly with multi-threading enabled:

<installed LLVM tools, llvm-config.exe in my path>
<downloaded source from https://android.googlesource.com/toolchain/lld>
cd lld
mkdir build
cd build
cmake -G "Visual Studio 15 2017" -A x64 -T host=x64 ..
cmake --build . --target ALL_BUILD --config Release
copy Release\bin\ld.lld.exe \AndroidTools\android-ndk-r18b\toolchains\llvm\prebuilt\windows-x86_64\bin /Y

Environment:
Windows 10 64-bit
Intel i3 8300, 16GB ram, 250GB NVMe drive
ABI= tried armeabi-v7a, armeabi-v8a
Android build tools= 28.0.3
Android platform API= tried 21, 26, 28
Gradle= 4.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载