-
Notifications
You must be signed in to change notification settings - Fork 526
Proposal: ability to statically link against C++ stdlib #1497
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
Conversation
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.
Thanks, would you be able to add a test case for it?
Or just test that it works for your local project?
I would be happy to add test case for it, but It will be highly depending on host environment. I mean for environment where this test will be run, we need to be sure that somewhere in the system there's a file If it's not a problem to set CI to meet this requirement, I'll do that Also I tested it locally for my project and it works as expected |
Yes you can change our ci to install the libstdc++.a |
Took a look at tests, If I got it right, the main way of testing is checking emitted C compiler flags, but I'm a little bit confused how to test static linking of C++ stdlib, because it goes to stdout as @NobodyXu Could you approximately describe how do you see the test case please? I'm stuck at this point |
https://github.com/rust-lang/cc-rs/blob/main/dev-tools/cc-test/build.rs we have a build script to test cc functionality, I think you can add another workspace there |
Wrote the test for Linux. I do not like the part with invoking g++ to find libstdc++.a file, but it's the best I can come up with. Unfortunately, linker will not automatically find static .a file like it does for shared .so file Hope you have some ideas about that |
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.
Thank you, I think the test is good enough to ensure it's working!
Hi everyone!
I want to create a little proposal. It's very common situation when you need to statically link C++ stdlib to your binary. Usually it makes your binary a little bit more portable, especially if your app will be distributed to old systems. So this PR introduce an ability to explicitly say that you want to statically link C++ stdlib
Also maybe it will be useful to have a function to set a path where stdlib in .a format can be found, but I'm not sure about this one