Skip to content

Fix to build with C++ environment #1

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

blmarket
Copy link

C++ requires additional runtime to be linked by rust linker.

Reference:
rust-lang/rust#36710 (comment)

C++ requires additional runtime to be linked by rust linker.

Reference:
rust-lang/rust#36710 (comment)
@blmarket
Copy link
Author

Note: my production build failed in vanilla musl-cross-make environment while linking libc.a, error due to it was compiled without -fPIE. Adding -fPIE to musl CFLAGS, and rebuilding musl-cross-make resolved the issue.

@harrysarson
Copy link
Owner

Thanks for the pull request. This was an experiment I have since abandoned (so I am probably not going to merge this pull request).

Very interesting solution, I like it. In the end I got close to fixing this problem by

  1. Linking with g++ rather than gcc
  2. Removing (manually) the -Bdynamic flags that dynamically link to libstdc++.

I belive the root issue (or feature request) probably lies with the cc crate which should provide some way to link statically to libstdc++ rather than dynamically.

Anyway, it turned out easier to port the c++ we needed to link in to rust than to fix the build so I gave up here. I would be interested to here about the problem you are trying to solve and please do tag me in future issues as I would be really interestedin finding out about any solutions

@jianshu93
Copy link

Hello all,
it this solved yet. I have exactly the same issue on Alpine linux. though my rust program successfully compiled but segmentation fault when trying to run it. Note that even with -C link-self-contained=on, ldd binary returns several musl dynamic library libc_musl-x86_64.so et.al. no idea how to solve it.

Thanks,

Jianshu

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 this pull request may close these issues.

3 participants