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

audit: fix static linking #109112

Merged
merged 2 commits into from Jan 23, 2021
Merged

audit: fix static linking #109112

merged 2 commits into from Jan 23, 2021

Conversation

KAction
Copy link
Contributor

@KAction KAction commented Jan 12, 2021

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

#pragma weak audit_strsplit_r
EOF
'' + stdenv.lib.optionalString stdenv.targetPlatform.isStatic ''
export LDFLAGS=-Wl,--whole-archive
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use NIX_LDFLAGS instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? As I was told in 100906 by @nh2, NIX_LDFLAGS should be used as last resort.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nh2 Does the same apply to LDFLAGS?

Does this overwrite LDFLAGS here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the same apply to LDFLAGS?

Sorry, I saw this only now.

The same does not apply to LDFLAGS; setting LDFLAGS is fine because it's picked up by the build system (autoconf here, whose main configuration method is via these environment variables).

Only the NIX_*FLAGS are sneaked past the build systems directly to the linker.

@jonringer
Copy link
Contributor

/rebase-staging

@jonringer
Copy link
Contributor

I rebased onto staging due to the number of rebuilds

@github-actions github-actions bot changed the base branch from master to staging January 12, 2021 14:45
Comment on lines 39 to 40
patches = [ ./patches/weak-symbols.patch ] ++
stdenv.lib.optional stdenv.hostPlatform.isMusl [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
patches = [ ./patches/weak-symbols.patch ] ++
stdenv.lib.optional stdenv.hostPlatform.isMusl [
patches = [ ./patches/weak-symbols.patch ]
++ stdenv.lib.optional stdenv.hostPlatform.isMusl [

@symphorien symphorien merged commit 7310aba into NixOS:staging Jan 23, 2021
# --whole-archive linker flag is required to be sure that linker
# correctly chooses strong version of symbol regardless of order of
# object files at command line.
+ stdenv.lib.optionalString stdenv.targetPlatform.isStatic ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been hostPlatform

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, done in 0034539 thanks @malbarbo! Just need to backport to 21.05.

@KAction KAction deleted the audit-static branch October 29, 2021 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants