Skip to content

toolchain(cross): use target-specific objcopy#6240

Merged
waruqi merged 1 commit intoxmake-io:devfrom
Doekin:cross-objcopy
Mar 23, 2025
Merged

toolchain(cross): use target-specific objcopy#6240
waruqi merged 1 commit intoxmake-io:devfrom
Doekin:cross-objcopy

Conversation

@Doekin
Copy link
Contributor

@Doekin Doekin commented Mar 23, 2025

The cross toolchain currently lacks support for objcopy, causing a full file copy to be performed when the build mode is releasedbg.

Current behavior:

When building with the cross toolchain and releasedbg mode, the process performs a direct file copy:

$ xmake f -c -vD -m releasedbg -p cross --cross=aarch64-linux-gnu-
$ xmake -r -vD hello_c
[ 50%]: cache compiling.releasedbg src/hello.c
/usr/bin/aarch64-linux-gnu-gcc -c -g -Wall -Wextra -Wpedantic -O3 -DNDEBUG -o build/.objs/hello_c/cross/arm64/releasedbg/src/hello.c.o src/hello.c
[ 75%]: linking.releasedbg hello_c
/usr/bin/aarch64-linux-gnu-g++ -o build/cross/arm64/releasedbg/hello_c build/.objs/hello_c/cross/arm64/releasedbg/src/hello.c.o
[ 75%]: generating.releasedbg hello_c.sym
> copy build/cross/arm64/releasedbg/hello_c to build/cross/arm64/releasedbg/hello_c.sym
/usr/bin/aarch64-linux-gnu-strip -s build/cross/arm64/releasedbg/hello_c

Behavior after the change:

With the proposed fix, the cross toolchain now uses the target-specific objcopy to handle debug symbols:

$ xmake f -c -vD -m releasedbg -p cross --cross=aarch64-linux-gnu-
$ xmake -r -vD hello_c
[ 50%]: cache compiling.releasedbg src/hello.c
/usr/bin/aarch64-linux-gnu-gcc -c -g -Wall -Wextra -Wpedantic -O3 -DNDEBUG -o build/.objs/hello_c/cross/arm64/releasedbg/src/hello.c.o src/hello.c
[ 75%]: linking.releasedbg hello_c
/usr/bin/aarch64-linux-gnu-g++ -o build/cross/arm64/releasedbg/hello_c build/.objs/hello_c/cross/arm64/releasedbg/src/hello.c.o
[ 75%]: generating.releasedbg hello_c.sym
/usr/bin/aarch64-linux-gnu-objcopy --only-keep-debug build/cross/arm64/releasedbg/hello_c build/cross/arm64/releasedbg/hello_c.sym
/usr/bin/aarch64-linux-gnu-strip -s build/cross/arm64/releasedbg/hello_c
/usr/bin/aarch64-linux-gnu-objcopy --add-gnu-debuglink=build/cross/arm64/releasedbg/hello_c.sym build/cross/arm64/releasedbg/hello_c

@waruqi waruqi merged commit 15ba86c into xmake-io:dev Mar 23, 2025
22 checks passed
@waruqi waruqi added this to the v2.9.9 milestone Mar 23, 2025
@Doekin Doekin deleted the cross-objcopy branch May 16, 2025 04:38
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