Skip to content

(autotools) fix ld override when ld binary is not in the same directo…#6425

Merged
waruqi merged 2 commits intoxmake-io:devfrom
Arthapz:fix-ld-autotools
May 14, 2025
Merged

(autotools) fix ld override when ld binary is not in the same directo…#6425
waruqi merged 2 commits intoxmake-io:devfrom
Arthapz:fix-ld-autotools

Conversation

@Arthapz
Copy link
Member

@Arthapz Arthapz commented May 12, 2025

shared packages installation are broken when --sdk is set with a bin directory without ld binary
e.g when using llvm toolchain with --sdk, ld binary may not exists in the bin directory and result with a non-existent path which make autotools use clang++ as linker wich prevent .so to be generated

name = name:gsub("g%+%+$", "ld")
name = name:gsub("g%+%+%-%d+", "ld")
envs.LD = dir and path.join(dir, name) or name
local ld = find_tool("ld")
Copy link
Member

Choose a reason for hiding this comment

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

Using find_tool may find the system ld instead of the ld corresponding to the current package toolchain, which may break many packages, especially for some cross-compilation toolchains.

/sdk/bin/linux-arm-clang -> /sdk/bin/linux-arm-ld

now:

/sdk/bin/linux-arm-clang -> /usr/bin/ld

Copy link
Member Author

Choose a reason for hiding this comment

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

right, maybe i can add the path of the compiler in the search directory list of find_tool, would it work ?

Copy link
Member

@waruqi waruqi May 12, 2025

Choose a reason for hiding this comment

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

no, It is difficult to keep the package toolchain consistent with the result of find_tool. I still recommend that all tool-related information be obtained from package:build_getenv, which can correctly obtain the sdk/bin path corresponding to clang/ld.

Therefore, I currently use the path file name replacement method to obtain ld under the corresponding toolchain sdk path.

Copy link
Member Author

Choose a reason for hiding this comment

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

i changed it to only fallback on find_tool if , is it more acceptable ? we can't use package:build_getenv because the point here is that only ld work with autotools, when clang++ is set as ld, it doesn't generate .so for shared libraries

@Arthapz Arthapz marked this pull request as draft May 12, 2025 14:39
@Arthapz Arthapz force-pushed the fix-ld-autotools branch from 13ee94a to 03b532a Compare May 13, 2025 18:26
@Arthapz Arthapz force-pushed the fix-ld-autotools branch from 03b532a to e7eab72 Compare May 13, 2025 18:32
@Arthapz Arthapz marked this pull request as ready for review May 13, 2025 20:02
@waruqi waruqi added this to the v3.0.0 milestone May 14, 2025
@waruqi waruqi merged commit 29ee4b4 into xmake-io:dev May 14, 2025
22 checks passed
@Arthapz Arthapz deleted the fix-ld-autotools branch September 18, 2025 09:22
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

Successfully merging this pull request may close these issues.

2 participants