You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've included complete steps to reproduce my issue.
Describe the bug
Alire includes these compiler switches in all its build profiles:
,"-ffunction-sections"-- Separate ELF section for each function
,"-fdata-sections"-- Separate ELF section for each variable
But it doesn't include -gc-sections to the linker in any of the profiles. Can that be considered a bug, or is there a reason for that? As far as I know, these options only make sense when the linker performs garbage collection. The GCC documentation seems to suggest that you should use these options with care, and the GNAT documentation only mentions the compiler switches in combination to the linker switches.
To Reproduce
Steps to reproduce the behavior:
alr init gc_sections
alr build -- -v
The output does contain -ffunction-sections -fdata-sections in the compilation command, but not -Wl,-gc-sections in the linker command:
$ alr build -- -v
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
ⓘ Building gc_sections=0.1.0-dev/gc_sections.gpr...
object directory "/home/mgr/tmp/gc_sections/obj/development" created for project Gc_Sections
exec directory "/home/mgr/tmp/gc_sections/bin" created for project Gc_Sections
Changing to object directory of "Gc_Sections": "/home/mgr/tmp/gc_sections/obj/development/"
/home/mgr/.local/share/alire/toolchains/gnat_native_14.2.1_06bb3def/bin/gcc -c -x ada -gnatA -Og -ffunction-sections -fdata-sections -g -gnatwa -gnatw.X -gnatVa -gnaty3 -gnatya -gnatyA -gnatyB -gnatyb -gnatyc -gnaty-d -gnatye -gnatyf -gnatyh -gnatyi -gnatyI -gnatyk -gnatyl -gnatym -gnatyn -gnatyO -gnatyp -gnatyr -gnatyS -gnatyt -gnatyu -gnatyx -gnatW8 -gnatec=/tmp/GNAT-TEMP-000003.TMP -gnatem=/tmp/GNAT-TEMP-000004.TMP /home/mgr/tmp/gc_sections/src/gc_sections.adb
/home/mgr/.local/share/alire/toolchains/gprbuild_22.0.1_24dfc1b5/libexec/gprbuild/gprbind gc_sections.bexch
/home/mgr/.local/share/alire/toolchains/gnat_native_14.2.1_06bb3def/bin/gnatbind -o b__gc_sections.adb /home/mgr/tmp/gc_sections/obj/development/gc_sections.ali -Es -x -F=/tmp/GNAT-TEMP-000005.TMP -O=/tmp/GNAT-TEMP-000007.TMP
/home/mgr/.local/share/alire/toolchains/gnat_native_14.2.1_06bb3def/bin/gcc -c -x ada -gnatA -c -gnatA -gnatWb -gnatiw -gnatws -Og -ffunction-sections -fdata-sections -g -mtune=generic -march=x86-64 b__gc_sections.adb -o b__gc_sections.o
gcc gc_sections.o b__gc_sections.o -L/home/mgr/tmp/gc_sections/obj/development/ -L/home/mgr/tmp/gc_sections/obj/development/ -L/home/mgr/.local/share/alire/toolchains/gnat_native_14.2.1_06bb3def/lib/gcc/x86_64-pc-linux-gnu/14.2.0/adalib/ -static-libgcc /home/mgr/.local/share/alire/toolchains/gnat_native_14.2.1_06bb3def/lib/gcc/x86_64-pc-linux-gnu/14.2.0/adalib/libgnat.a -ldl -Wl,-rpath-link,/home/mgr/.local/share/alire/toolchains/gnat_native_14.2.1_06bb3def/lib/gcc/x86_64-pc-linux-gnu/14.2.0//adalib -Wl,-z,origin,-rpath,$ORIGIN/..//obj/development:$ORIGIN/../../..//.local/share/alire/toolchains/gnat_native_14.2.1_06bb3def/lib/gcc/x86_64-pc-linux-gnu/14.2.0/adalib -o /home/mgr/tmp/gc_sections/bin//gc_sections
✓ Build finished successfully in 0.57 seconds.
Expected Behavior -Wl,--gc-sections is added to the default generated gpr file for binary crates, so that the other switches make something useful. Maybe could be done only in the release profile, but then, why to include the compilation switches in the other profiles?
alr version
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
APPLICATION
alr version: 2.0.1
libalire version: 2.0.1
compilation date: 2024-03-21 11:05:29
compiled with version: 10.5.0
CONFIGURATION
settings folder: /home/mgr/.config/alire
cache folder: /home/mgr/.local/share/alire
vault folder: /home/mgr/.local/share/alire/releases
build folder: /home/mgr/.local/share/alire/builds
temp folder: /run/user/1000
force flag: FALSE
non-interactive flag: FALSE
community index branch: stable-1.3.0
compatible index versions: ^1.1 & <=1.3.0
indexes folder: /home/mgr/.config/alire/indexes
indexes metadata: OK
index #1: (community) git+https://github.com/alire-project/alire-index#stable-1.3.0
toolchain folder: /home/mgr/.local/share/alire/toolchains
toolchain assistant: disabled
tool #1 gnat: gnat_native=14.2.1
tool #2 gprbuild: gprbuild=22.0.1
system package manager: /usr/bin/apt
distro detection disabled: FALSE
WORKSPACE
root status: VALID
root release: gc_sections=0.1.0-dev
root load error: none
root folder: /home/mgr/tmp/gc_sections
current folder: /home/mgr/tmp/gc_sections
SYSTEM
distribution: UBUNTU
host-arch: X86_64
os: LINUX
target: NATIVE
toolchain: SYSTEM
word-size: BITS_64
The text was updated successfully, but these errors were encountered:
mgrojo
changed the title
Consider including -Wl,-gc-sections as linker switch to the generated GPR for binary crates-Wl,-gc-sections linker switch is never included
Dec 30, 2024
Checklist
alr version
.Describe the bug
Alire includes these compiler switches in all its build profiles:
But it doesn't include
-gc-sections
to the linker in any of the profiles. Can that be considered a bug, or is there a reason for that? As far as I know, these options only make sense when the linker performs garbage collection. The GCC documentation seems to suggest that you should use these options with care, and the GNAT documentation only mentions the compiler switches in combination to the linker switches.To Reproduce
Steps to reproduce the behavior:
alr init gc_sections
alr build -- -v
-ffunction-sections -fdata-sections
in the compilation command, but not-Wl,-gc-sections
in the linker command:Expected Behavior
-Wl,--gc-sections
is added to the default generated gpr file for binary crates, so that the other switches make something useful. Maybe could be done only in the release profile, but then, why to include the compilation switches in the other profiles?alr
versionThe text was updated successfully, but these errors were encountered: