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

Can't link dub with i686 LDC 0.15.1 #813

Closed
mihails-strasuns opened this issue Dec 18, 2014 · 11 comments · Fixed by #819
Closed

Can't link dub with i686 LDC 0.15.1 #813

mihails-strasuns opened this issue Dec 18, 2014 · 11 comments · Fixed by #819

Comments

@mihails-strasuns
Copy link
Contributor

Have tried to package dub (release 0.9.22) built with LDC in shared library mode:

    cmake \
    -DCMAKE_SKIP_RPATH=ON \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DINCLUDE_INSTALL_DIR=/usr/include/dlang/ldc \
    -DBUILD_SHARED_LIBS=ON \
    ..
    make

Works with no issues on x64_86 systems, but on i686 there is a linker failure:

/usr/lib/libldruntime-debug.so: undefined reference to `__mulodi4'
collect2: error: ld returned 1 exit status

Any ideas?

@dnadlinger
Copy link
Member

The issue probably is in the core.checkedint.mul… implementation for 64 bit types. We forward to the LLVM intrinsic here, but apparently, it requires runtime support that is not found in libgcc, but only in the LLVM compiler_rt: http://llvm.org/bugs/show_bug.cgi?id=14469

If this is indeed the issue (didn't check), I'm not sure why the unit tests for the module pass on Travis, though. Apparently, we aren't running any 32 bit shared library tests (shudder), but one would expect the same issue to occur on static builds too.

@mihails-strasuns
Copy link
Contributor Author

If this is the case, is there anything I can do to workaround this issue as a packager?

@dnadlinger
Copy link
Member

I don't think so, it is something for us to fix in the next point release. If my suspicion regarding the root cause is correct, it might be as simple as only using the LLVM intrinsic on platforms where we know it works without library calls (not X86).

@dnadlinger
Copy link
Member

So, actually, there is something you can do: Verify where the reference is and submit a patch. ;)

@mihails-strasuns
Copy link
Contributor Author

Affirmative, will get to it soon-ish.

@mihails-strasuns
Copy link
Contributor Author

Erm, but how can I find what generates reference to this specific symbol? Grepping for it in neither LDC sources nor LLVM headers finds anything.

# i686
[dicebot@microfog trunk]$ nm -D usr/lib/libldruntime-debug.so | grep __mulodi4
         U __mulodi4
[dicebot@microfog trunk]$ nm -D usr/lib/libldruntime.so | grep __mulodi4
         U __mulodi4
# x64_86
[dicebot@microfog trunk]$ nm -D usr/lib/libldruntime-debug.so.so | grep __mulodi4
# nothing

@mihails-strasuns
Copy link
Contributor Author

reddit comment http://www.reddit.com/r/programming/comments/2pvf68/armv7_vs_x8664_pathfinding_benchmark_of_c_d_go/cn0hq95 , says they ship/link compiler-rt to address same issue in Rust

@dnadlinger
Copy link
Member

Yes, this might also be an option. For the moment, the simple fix would be to just use the slow upstream implementations as core.checkedint isn't really used right now (as far as I know). We should definitely consider at least incorporating the relevant parts of compiler-rt in the future, though.

@mihails-strasuns
Copy link
Contributor Author

Using this diff as a workaround seems to help : https://github.com/Dicebot/Arch-PKGBUILDs/blob/master/ldc/mul.diff

@mihails-strasuns
Copy link
Contributor Author

Would you prefer to keep this issue open as a reminder for pending better solution or should I close it?

@dnadlinger
Copy link
Member

Let's keep it open until we actually fix the issue in our tree. I'm working against a deadline right now, though, so I can't really spend any time on the necessary testing, however trivial it might be.

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

Successfully merging a pull request may close this issue.

2 participants