Skip to content

Conversation

fitzsim
Copy link

@fitzsim fitzsim commented Aug 11, 2025

This patch builds annobin.so.0.0.0 and installs it to the GCC plugins directory of the devkit. annobin.so.0.0.0 is built with the same CFLAGS, CXXFLAGS and LDFLAGS as other target libraries like gmp.

I only tested on the GCC 11.3.0 devkit, so throughout Tools.gmk I made annobin logic conditional on annobin_ver being set.

Tested on x86-64 and ppc64le Fedora 42 (example ppc64le run follows):

[root@fedora tmp]$ export PATH=/opt/devkit/ppc64le-linux-gnu-to-ppc64le-linux-gnu/bin:$PATH
[root@fedora tmp]$ export LD_LIBRARY_PATH=/opt/devkit/ppc64le-linux-gnu-to-ppc64le-linux-gnu/lib64
[root@fedora tmp]$ ldd /opt/devkit/ppc64le-linux-gnu-to-ppc64le-linux-gnu/lib/gcc/ppc64le-linux-gnu/11.3.0/plugin/annobin.so.0.0.0
	linux-vdso64.so.1 (0x00007fffa79c0000)
	libstdc++.so.6 => /opt/devkit/ppc64le-linux-gnu-to-ppc64le-linux-gnu/lib64/libstdc++.so.6 (0x00007fffa7600000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fffa74b0000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fffa7200000)
	libgcc_s.so.1 => /opt/devkit/ppc64le-linux-gnu-to-ppc64le-linux-gnu/lib64/libgcc_s.so.1 (0x00007fffa7900000)
	/lib64/ld64.so.2 (0x00007fffa79d0000)
[root@fedora tmp]$ type -P gcc
/opt/devkit/ppc64le-linux-gnu-to-ppc64le-linux-gnu/bin/gcc
[root@fedora tmp]$ cat > test.c <<EOF
#include <stdio.h>

int main()
{
  printf("Hello, World!\n");
  return 0;
}
EOF
[root@fedora tmp]$ strace -f -e openat gcc -fplugin=annobin -Wall -o test.anno test.c 2>&1 | grep annobin.so
[pid  1870] openat(AT_FDCWD, "/opt/devkit/ppc64le-linux-gnu-to-ppc64le-linux-gnu/bin/../lib/gcc/ppc64le-linux-gnu/11.3.0/plugin/annobin.so", O_RDONLY|O_CLOEXEC) = 3
[root@fedora tmp]$ readlink -f /opt/devkit/ppc64le-linux-gnu-to-ppc64le-linux-gnu/bin/../lib/gcc/ppc64le-linux-gnu/11.3.0/plugin/annobin.so
/opt/devkit/ppc64le-linux-gnu-to-ppc64le-linux-gnu/lib/gcc/ppc64le-linux-gnu/11.3.0/plugin/annobin.so.0.0.0
[root@fedora tmp]$ gcc -fplugin=annobin -Wall -o test test.c
[root@fedora tmp]$ objdump -x test | grep annobin
 27 .annobin.notes 000000a4  0000000000000000  0000000000000000  0001013b  2**0
[root@fedora tmp]$ gcc -Wall -o test test.c
[root@fedora tmp]$ objdump -x test | grep annobin
[root@fedora tmp]$

@gnu-andrew
Copy link

This looks good to me.

I did notice that the log.config line is the same as upstream rather than our patched version but I think this is correct for a potentially upstreamable patch, and we can change that in a follow-on.

Another advantage of annobin_ver is we could potentially propose this upstream with it unset and then just patch in a version to make it work for us downstream.

@fitzsim
Copy link
Author

fitzsim commented Aug 14, 2025

OK, I pushed an additional patch that removes a trailing space, and that updates annobin configure logging to match the other targets.

Agreed about annobin_ver. It can even be set on the command line (e.g., make BASE_OS=RHEL annobin_ver=annobin-12.99). Let me know if you want me to not set it in the current patch, and specify it in the RPM spec file instead.

@fitzsim fitzsim marked this pull request as ready for review August 14, 2025 19:49
@gnu-andrew
Copy link

OK, I pushed an additional patch that removes a trailing space, and that updates annobin configure logging to match the other targets.

Thanks for this and keeping it seperate.

Agreed about annobin_ver. It can even be set on the command line (e.g., make BASE_OS=RHEL annobin_ver=annobin-12.99). Let me know if you want me to not set it in the current patch, and specify it in the RPM spec file instead.

Yes, can you modify the first commit to do this. Then we have a clean upstream patch.

Also remove a trailing space character after binutils log.config.
@fitzsim fitzsim force-pushed the devkit-annobin branch 2 times, most recently from e5226d3 to 2d791e6 Compare August 27, 2025 21:20
@fitzsim
Copy link
Author

fitzsim commented Aug 27, 2025

Agreed about annobin_ver. It can even be set on the command line (e.g., make BASE_OS=RHEL annobin_ver=annobin-12.99). Let me know if you want me to not set it in the current patch, and specify it in the RPM spec file instead.

Yes, can you modify the first commit to do this. Then we have a clean upstream patch.

Done.

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