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

Linking order not preserved in pkg.lflags #429

Open
simonratner opened this issue Mar 4, 2021 · 0 comments
Open

Linking order not preserved in pkg.lflags #429

simonratner opened this issue Mar 4, 2021 · 0 comments

Comments

@simonratner
Copy link
Contributor

simonratner commented Mar 4, 2021

When specifying additional libraries to be linked with pkg.lflags, the order of the libraries is not preserved. Instead, flags seem to be sorted in alphabetical order.

This is a problem when symbols in one of the libraries are defined in another, e.g. the following fails to link:

nm liba.a

00000001 T foo

nm libb.a

00000001 U foo

cat pkg.yml:

pkg.lflags:
  - "-lb"
  - "-la"

Normally, foo from libb will be added to the undefined list, and then matched to foo in liba once it is encountered. However newt actually executes gcc ... -la -lb, which strips the unused foo from liba before processing libb and results in an undefined reference to foo.

A workaround is to rename or symlink the libraries into the order you wish them to be linked 🤮

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

No branches or pull requests

1 participant