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

Add no_default_libraries target linker option #28578

Merged
merged 1 commit into from
Sep 22, 2015

Conversation

gandro
Copy link
Contributor

@gandro gandro commented Sep 21, 2015

This patch basically adds a target option for omitting the -nodefaultlibs flag when invoking the linker. I am not sure if this is the correct or only way to approach this problem, so any feedback is welcome.

Motivation: I'm currently working on a Rust target specification for the rumprun unikernel. rumprun is based on rump kernels and uses NetBSDs libc and drivers to provide a POSIXy environment. It provides its own linker wrapper that generates binaries which can be "baked" into a unikernel after configuration. Using -nodefaultlibs on the rumprun linker will prevent it from selecting the search paths for the rumprun libraries. My current target implementation for rumprun is here: gandro/rust@295744b

Currently, only a target that is_like_windows will omit the -nodefaultlibs flag, but since rumprun is not like Windows otherwise, I think a separate flag makes more sense. This might be a breaking change for target specifications that have the is_like_windows option set to true. Such targets need to set no_default_libraries to false in order to restore the old behavior.

If set to false, `-nodefaultlibs` is not passed to the linker. This
was the default behavior on Windows, but it should be configurable
per target.

This is a [breaking-change] for target specifications that have
the `is_like_windows` option set to true. Such targets need to
set `no_default_libraries` to false in order to restore the old
behavior.
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nrc (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@nrc
Copy link
Member

nrc commented Sep 22, 2015

r? @alexcrichton

@rust-highfive rust-highfive assigned alexcrichton and unassigned nrc Sep 22, 2015
@alexcrichton
Copy link
Member

@bors: r+ 920f32b

Thanks!

@bors
Copy link
Contributor

bors commented Sep 22, 2015

⌛ Testing commit 920f32b with merge f17cc4c...

bors added a commit that referenced this pull request Sep 22, 2015
This patch basically adds a target option for omitting the `-nodefaultlibs` flag when invoking the linker. I am not sure if this is the correct or only way to approach this problem, so any feedback is welcome.

Motivation: I'm currently working on a Rust target specification for the [rumprun](/rumpkernel/rumprun) unikernel. rumprun is based on rump kernels and uses NetBSDs libc and drivers to provide a POSIXy environment. It provides its own linker wrapper that generates binaries which can be "baked" into a unikernel after configuration. Using `-nodefaultlibs` on the rumprun linker will prevent it from selecting the search paths for the rumprun libraries. My current target implementation for rumprun is here: gandro/rust@295744b

Currently, only a target that `is_like_windows` will omit the `-nodefaultlibs` flag, but since rumprun is not like Windows otherwise, I think a separate flag makes more sense. This might be a breaking change for target specifications that have the `is_like_windows` option set to true. Such targets need to set `no_default_libraries` to false in order to restore the old behavior.
@bors bors merged commit 920f32b into rust-lang:master Sep 22, 2015
@brson brson added the relnotes Marks issues that should be documented in the release notes of the next release. label Sep 25, 2015
kennytm added a commit to kennytm/rust that referenced this pull request Sep 21, 2018
Use no_default_libraries for all NetBSD flavors

The no_default_libraries was introduced in rust-lang#28578 because the
NetBSD-based rumprun needed to disable the link flag.
This moves the definition to be used by all NetBSD linker flavors to
close rust-lang#49627.

A different solution would be adding -lc but as there is no platform
with explicit -lc, this approach is used.
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Sep 22, 2018
Use no_default_libraries for all NetBSD flavors

The no_default_libraries was introduced in rust-lang#28578 because the
NetBSD-based rumprun needed to disable the link flag.
This moves the definition to be used by all NetBSD linker flavors to
close rust-lang#49627.

A different solution would be adding -lc but as there is no platform
with explicit -lc, this approach is used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants