You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Have a better solution to AOT linker discovery #2645
At the moment we are relying on the IREE_LLVMAOT_LINKER_PATH environment variable for discovering the linker for LLVM AOT CodeGen. This is quite fragile and obscure. Figure out a better way for doing it. For example, for Android cross-compilation we can probably do #2391.
Totally agree the environment variable was a short term solution to support cross platform codegen. Will need to do a generalizing version #2391 so build system discover and populates target platform linker path along with providing a flag to override this value.
In the meantime, can we document what developers should do to make sure they can build/test? I think this env variable isn't documented in any of our getting started guides and a few people have had test failures because of it.
In the meantime, can we document what developers should do to make sure they can build/test? I think this env variable isn't documented in any of our getting started guides and a few people have had test failures because of it.
Yeah, its only documented for android build. Getting rid of it is better though!
agreed - the intent with getToolPath() was that we could have that search and then cache the result so we aren't searching N times per compilation for every link we do.
We can also - if the IREE-specific envvar isn't set - fallback and use $CC and let the compiler (gcc/clang) figure out how to find the linker. Just clang our_output_object.o -Wl,-linker-flags-here -o our_output_library.so. On Windows we may still need vswhere, but I feel like I'm ok with that or telling users to run vcvarsall for now (since we don't even have a bot for that yet I don't want it to block things).
yep! if we use $CC it takes care of this (mostly) for us, just as if you were building yourself by hand:
export CC=$NDK/toolchains/llvm/prebuilt/$HOST_TAG/bin/aarch64-linux-android21-clang++
$CC -shared foo.c -o foo.so # ndk cc used to link
iree-translate input.mlir -o output.vmbf # ndk cc used to link
The other thing we should try as part of this in follow-on is LTO. If we know we want it anyway (we do) it may be easiest to just jump to it instead of getting things working first in a state we know we don't want and then rewriting it all/figuring it all out again immediately afterward.
With LTO we could use whatever triples the user has linker support for vs. what we decide to link in to our binaries (x86/arm64/etc today). If the user has mips or arm32 (or riscv!) or whatever we would just be able to use those with no changes needed for us. See #3736.
My immediate motivation here is keeping the Linux getting started steps functional for most users, with LLVM AOT enabled by default. The Windows steps already recommend running vcvarsall.bat. Deeper / more general improvements can be secondary to that IMO. If it's easy to do all at once then great, I'm just not comfortable in this "some tests are disabled for [reasons] state" for long.
Agreed - what we're talking about here is the difference between 10 lines of code writing out a native .o as it is today or 1 line of code writing out a .bc. Same shape of problem, same work to figure out the CC path. I don't want to see this take a week because there's futzing with things needed we don't need to solve anyway. If someone can literally go hack in getenv(IREE_LLVMAOT_LINKER || CC) and this all works then of course do that first. I'd have expected you all to have already done that if it was that easy, though ;)
I'm still seeing two TODOs referencing this issue. My preference is that we don't close issues until all the TODOs are cleaned up as well. Otherwise tech debt tends to not get cleaned up
@GMNGeoffrey, fair enouph will create a new issue related to the TODOs which are:
1- LinkerTool support when compiling for android target on windows host.
2- LinkerTool support when compiling for linux target on windows host.
Activity
asaadaldien commentedon Jul 24, 2020
Totally agree the environment variable was a short term solution to support cross platform codegen. Will need to do a generalizing version #2391 so build system discover and populates target platform linker path along with providing a flag to override this value.
GMNGeoffrey commentedon Jul 28, 2020
In the meantime, can we document what developers should do to make sure they can build/test? I think this env variable isn't documented in any of our getting started guides and a few people have had test failures because of it.
asaadaldien commentedon Jul 28, 2020
Yeah, its only documented for android build. Getting rid of it is better though!
GMNGeoffrey commentedon Jul 28, 2020
I think this is not closed? We still need a better way to do this :-D
GMNGeoffrey commentedon Jul 28, 2020
Maybe GitHub auto-closed it because your commit description said "#2645 is resolved"?
Revert addition of DYLIB-LLVM-AOT as a default backend (#2702)
Revert addition of DYLIB-LLVM-AOT as a default backend (iree-org#2702)
Revert addition of DYLIB-LLVM-AOT as a default backend (iree-org#2702)
8 remaining items
ScottTodd commentedon Nov 18, 2020
I'm resolving those TODOs right now.
GMNGeoffrey commentedon Nov 18, 2020
Great! Let's close the issue when the cleanup is complete
ScottTodd commentedon Nov 20, 2020
I think the default tool path should be looked at a bit more closely prior to merging #3928 and enabling LLVM AOT by default for builds/tests. I have
/usr/bin/ld, but we default told.lld: https://github.com/google/iree/blob/bf84e445b846f58295b0e903383ae2c82e642707/iree/compiler/Dialect/HAL/Target/LLVM/AOT/internal/UnixLinkerTool.cpp#L32-L35Because of this, I still need to set
IREE_LLVMAOT_LINKER_PATH=/usr/bin/ldin my environment (or--test_envunder Bazel).ld(https://linux.die.net/man/1/ld) is typically installed on Linux whileld.lld(https://lld.llvm.org/#using-lld) comes with LLVM but isn't hooked up as part of our build process. Can we search for both on$PATHand pick our preference?On Windows, https://github.com/microsoft/vswhere looks nice, but is not installed by default. Requiring
vcvarsallisn't unreasonable, but takes a bit of extra IDE setup.benvanik commentedon Nov 20, 2020
agreed - the intent with getToolPath() was that we could have that search and then cache the result so we aren't searching N times per compilation for every link we do.
We can also - if the IREE-specific envvar isn't set - fallback and use $CC and let the compiler (gcc/clang) figure out how to find the linker. Just
clang our_output_object.o -Wl,-linker-flags-here -o our_output_library.so. On Windows we may still need vswhere, but I feel like I'm ok with that or telling users to run vcvarsall for now (since we don't even have a bot for that yet I don't want it to block things).asaadaldien commentedon Nov 20, 2020
And maybe we can make cross compiling more explicit so the tool will search outside $CC paths, e.g for android search in $ANDROID_NDK subdirectories
benvanik commentedon Nov 20, 2020
yep! if we use $CC it takes care of this (mostly) for us, just as if you were building yourself by hand:
asaadaldien commentedon Nov 20, 2020
IIRC for we always have have CC points to host side clang, I think we need something like CC_TARGET points to android toolchain path?
benvanik commentedon Nov 20, 2020
Correct!
If we used targetTriple.isAndroid() then we can multitarget by building the toolchain path:
https://developer.android.com/ndk/guides/other_build_systems#overview
(we can get the host triple from LLVM and then the target triple is given to us)
All we'd need is ANDROID_NDK.
Similarly MSVC can do the same thing.
benvanik commentedon Nov 20, 2020
The other thing we should try as part of this in follow-on is LTO. If we know we want it anyway (we do) it may be easiest to just jump to it instead of getting things working first in a state we know we don't want and then rewriting it all/figuring it all out again immediately afterward.
With LTO we could use whatever triples the user has linker support for vs. what we decide to link in to our binaries (x86/arm64/etc today). If the user has mips or arm32 (or riscv!) or whatever we would just be able to use those with no changes needed for us. See #3736.
Relevant to this issue too is their linker discovery/handling, which we may be able to take some flags from:
https://github.com/ldc-developers/ldc/pull/1840/files#diff-b8b40d59689f59dad18937a8c46c590b90158783da3634c53adbb111615a4b0f
ScottTodd commentedon Nov 20, 2020
My immediate motivation here is keeping the Linux getting started steps functional for most users, with LLVM AOT enabled by default. The Windows steps already recommend running
vcvarsall.bat. Deeper / more general improvements can be secondary to that IMO. If it's easy to do all at once then great, I'm just not comfortable in this "some tests are disabled for [reasons] state" for long.benvanik commentedon Nov 20, 2020
Agreed - what we're talking about here is the difference between 10 lines of code writing out a native .o as it is today or 1 line of code writing out a .bc. Same shape of problem, same work to figure out the CC path. I don't want to see this take a week because there's futzing with things needed we don't need to solve anyway. If someone can literally go hack in getenv(IREE_LLVMAOT_LINKER || CC) and this all works then of course do that first. I'd have expected you all to have already done that if it was that easy, though ;)
GMNGeoffrey commentedon Dec 2, 2020
I'm still seeing two TODOs referencing this issue. My preference is that we don't close issues until all the TODOs are cleaned up as well. Otherwise tech debt tends to not get cleaned up
asaadaldien commentedon Dec 2, 2020
@GMNGeoffrey, fair enouph will create a new issue related to the TODOs which are:
1- LinkerTool support when compiling for android target on windows host.
2- LinkerTool support when compiling for linux target on windows host.
Enable dylib-llvm-aot tests and switch from testing JIT to AOT. (#3928)