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

fix "as_needed" flag order #5631

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion xmake/modules/core/tools/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,13 @@ function nf_linkgroup(self, linkgroup, opt)
table.insert(prefix_flags, "-Wl,-Bstatic")
table.insert(suffix_flags, 1, "-Wl,-Bdynamic")
end
-- https://github.com/xmake-io/xmake/issues/5621
if as_needed then
Copy link
Member

Choose a reason for hiding this comment

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

为啥启用 as_needed , 反而是 "-Wl,--no-as-needed flags -Wl,--as-needed"? 怪怪的

Copy link
Contributor Author

Choose a reason for hiding this comment

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

因为默认就是 as_needed (只链接实际需要的)
而--no-as-needed 才是全部链接

Copy link
Contributor Author

Choose a reason for hiding this comment

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

或许改下option的名字? as_needed -> no_as_needed

Copy link
Member

Choose a reason for hiding this comment

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

用 false

-- https://github.com/xmake-io/xmake/issues/5621
table.insert(prefix_flags, "-Wl,--as-needed")
table.insert(suffix_flags, 1, "-Wl,--no-as-needed")
elseif as_needed == false then
table.insert(prefix_flags, "-Wl,--no-as-needed")
table.insert(suffix_flags, 1, "-Wl,--as-needed")
end
if whole then
table.insert(prefix_flags, "-Wl,--whole-archive")
Expand Down
Loading