Hey all-

I’m unable to build Swift on Fedora 36 and Rawhide while it does build on F35. I’ve been able to condense the entire issue down to the following sample code that demonstrates the problem:

nothing.S:

#define ASM_TYPE_FUNCTION(symbol) .type symbol, %function
#define ASM_SIZE(symbol) .size symbol, .-symbol
#define ASM_SYMBOL(symbol) symbol
#define ASM_WRAPPER_NAME(symbol) _interceptor##symbol

.comm _ZN14__interception10real_vforkE,8,8
.globl ASM_WRAPPER_NAME(vfork)
ASM_TYPE_FUNCTION(ASM_WRAPPER_NAME(vfork))
ASM_WRAPPER_NAME(vfork):
// Commenting out the line below makes it work
call *_ZN14__interception10real_vforkE(%rip)
ASM_SIZE(vfork)

And compiling this code with:

clang++ -fPIC -shared ./nothing.S

Results in the error:

/usr/bin/ld: /tmp/fun-1b3a0d.o: warning: relocation against _ZN14__interception10real_vforkE' in read-only section .text'
/usr/bin/ld: /tmp/fun-1b3a0d.o: relocation R_X86_64_PC32 against symbol `_ZN14__interception10real_vforkE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value

The issue is that I’m explicitly passing -fPIC but it seems to either be ignored or overridden somehow. I’m not well versed on assembly to make any kind of educated guess about what might be the problem/solution so I’m hoping someone more familiar might be able to shed some light on the issue.

Thanks!

Ron