-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
JITModule: rework/fix __udivdi3
handling
#8389
base: main
Are you sure you want to change the base?
Conversation
6b38b4e
to
3c9e720
Compare
@@ -550,6 +550,19 @@ if (WITH_SERIALIZATION_JIT_ROUNDTRIP_TESTING) | |||
target_compile_definitions(Halide PRIVATE WITH_SERIALIZATION_JIT_ROUNDTRIP_TESTING) | |||
endif () | |||
|
|||
if (NOT DEFINED Halide_COMPILER_BUILTIN_LIBRARY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argh, rebases aren't fun.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to blow up on Windows since MSVC isn't going to understand the --print-libgcc-file-name
flag. Under which circumstances exactly do we need to include the __udivdi3
symbol?
Similarly, there's an issue on macOS with it finding arguably the wrong builtins.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.builtins-x86_64.a
Can this all be guarded by if (CMAKE_SIZEOF_VOID_P EQUAL 4 AND ... something ...)
? LINUX AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
, maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under which circumstances exactly do we need to include the
__udivdi3
symbol?
Whenever the JIT might produce it but libHalide happens not to be linked
to the library that provides it. I'm hoping/wondering if we can just ask the clang
that we've found and are using to compile some runtimes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this kind-of works, and finds the right builtins on osx now:
https://buildbot.halide-lang.org/master/#/builders/171/builds/117
ninja: Entering directory `/Users/halidenightly/build_bot/worker/halide-testbranch-main-llvm20-arm-64-osx-cmake/halide-build'
ninja: error: '/Users/halidenightly/build_bot/worker/llvm-20-arm-64-osx/llvm-install/lib/clang/20/lib/darwin/libclang_rt.osx.a', needed by 'src/libHalide.19.0.0.dylib', missing and no known rule to make it
Similarly for windows:
https://buildbot.halide-lang.org/master/#/builders/157/builds/117
ninja: Entering directory `C:/build_bot/worker/halide-testbranch-main-llvm20-x86-64-windows-cmake/halide-build'
ninja: error: 'libgcc.a', needed by 'bin/Halide.dll', missing and no known rule to make it
I have absolutely no clue about win/osx, but that looks like the compiler-rt subproject is not enabled,
or, in osx case, the clang should be configured to use "system" libgcc from xcode?
3c9e720
to
0baca6c
Compare
The original workaround is very partial, and was not really working in my experience, even after making it non-GCC specific. Instead: 1. Ensure that the library that actually provides that symbol (as per the compiler used!) is actually linked into. This was not enough still. 2. Replace `HalideJITMemoryManager` hack with a more direct approach of actually telling the JIT the address of the symbol. 3. While there, move the symbol's forward definition to outside of namespaces. It's a global symbol, it makes sense to place it there. This makes python binding tests pass on i386, and i'm really happy about that. Refs. llvm/llvm-project#61289 Inspired by root-project/root#13286 Forwarded: halide#8389 Gbp-Pq: Name 0010-JITModule-rework-fix-__udivdi3-handling.patch
0baca6c
to
9e1b50b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more thought needs to be put into which library to link and when.
@@ -550,6 +550,19 @@ if (WITH_SERIALIZATION_JIT_ROUNDTRIP_TESTING) | |||
target_compile_definitions(Halide PRIVATE WITH_SERIALIZATION_JIT_ROUNDTRIP_TESTING) | |||
endif () | |||
|
|||
if (NOT DEFINED Halide_COMPILER_BUILTIN_LIBRARY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to blow up on Windows since MSVC isn't going to understand the --print-libgcc-file-name
flag. Under which circumstances exactly do we need to include the __udivdi3
symbol?
Similarly, there's an issue on macOS with it finding arguably the wrong builtins.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.builtins-x86_64.a
Can this all be guarded by if (CMAKE_SIZEOF_VOID_P EQUAL 4 AND ... something ...)
? LINUX AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
, maybe?
The original workaround is very partial, and was not really working in my experience, even after making it non-GCC specific. Instead: 1. Ensure that the library that actually provides that symbol (as per the compiler used!) is actually linked into. This was not enough still. 2. Replace `HalideJITMemoryManager` hack with a more direct approach of actually telling the JIT the address of the symbol. 3. While there, move the symbol's forward definition to outside of namespaces. It's a global symbol, it makes sense to place it there. This makes python binding tests pass on i386, and i'm really happy about that. Refs. llvm/llvm-project#61289 Inspired by root-project/root#13286 Forwarded: halide#8389 Gbp-Pq: Name 0010-JITModule-rework-fix-__udivdi3-handling.patch
9e1b50b
to
f634312
Compare
Ok, how about this? |
The original workaround is very partial, and was not really working in my experience, even after making it non-GCC specific. Instead: 1. Ensure that the library that actually provides that symbol (as per the compiler used!) is actually linked into. This was not enough still. 2. Replace `HalideJITMemoryManager` hack with a more direct approach of actually telling the JIT the address of the symbol. 3. While there, move the symbol's forward definition to outside of namespaces. It's a global symbol, it makes sense to place it there. This makes python binding tests pass on i386, and i'm really happy about that. Refs. llvm/llvm-project#61289 Inspired by root-project/root#13286 Forwarded: halide#8389 Gbp-Pq: Name 0010-JITModule-rework-fix-__udivdi3-handling.patch
f634312
to
66cdfbf
Compare
But as far as i can tell (from https://buildbot.halide-lang.org/master/#/builders/164/builds/123/steps/8/logs/stdio),
Shouldn't that be
Otherwise i'm not really sure how that can be detected. |
Is this still an active PR? |
The original workaround is very partial,
and was not really working in my experience,
even after making it non-GCC specific.
Instead:
HalideJITMemoryManager
hack with a more direct approach of actually telling the JIT the address of the symbol.This makes python binding tests pass on i386,
and i'm really happy about that.
https://ci.debian.net/packages/h/halide/testing/i386/50395069/#L2243
Refs. llvm/llvm-project#61289
Inspired by root-project/root#13286