Skip to content

Tools.gmk: Add annobin GCC plugin #37

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

Draft
wants to merge 1 commit into
base: devkit
Choose a base branch
from

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.

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