Hi Iain, > Currently the DSO support for D runtime is generated by the compiler in > every object, when really it is only required once per shared object. > > This patch moves that support logic from the compiler itself to the > library as part of the drtstuff code. The object files drtbegin.o and > drtend.o are now always linked in. > > Bootstrapped and tested on x86_64-linux-gnu/-m32/-mx32, with no > observable regressions. > > @Rainer, as you provided the original, would be good to validate this is > fine for Solaris too. I did, with mixed success: initially, the patch broke bootstrap on both i386-pc-solaris2.11 and sparc-sun-solaris2.11 linking libgdruntime.so: Text relocation remains referenced against symbol offset in file __start_minfo 0x2 gcc/drtbegin.o _D8drtstuff7dsoSlotPv 0x7 gcc/drtbegin.o _D8drtstuff7dsoDataS3gcc8sections6common15CompilerDSOData 0x1e gcc/drtbegin.o _D8drtstuff7dsoDataS3gcc8sections6common15CompilerDSOData 0x28 gcc/drtbegin.o __stop_minfo 0x2c gcc/drtbegin.o _D8drtstuff7dsoDataS3gcc8sections6common15CompilerDSOData 0x34 gcc/drtbegin.o _D8drtstuff7dsoDataS3gcc8sections6common15CompilerDSOData 0x39 gcc/drtbegin.o _D8drtstuff7dsoDataS3gcc8sections6common15CompilerDSOData 0x7 gcc/drtbegin.o _d_dso_registry 0x3e gcc/drtbegin.o _d_dso_registry 0xc gcc/drtbegin.o ld: fatal: relocations remain against allocatable but non-writable sections collect2: error: ld returned 1 exit status make[5]: *** [Makefile:1943: libgdruntime.la] Error 1 Solaris ld defaults to -z text, and gcc is still non-pic/pie by default. The attached patch fixes the issue by building drtbegin.o/drtend.o as libtool objects. There are a couple of caveats, though: * It directs gdc to libdruntime/gcc/.libs instead of libdruntime/gcc. I've no idea what happens when configuring with --disable-shared, building for targets without PIC support, or on Windows where that directory is called _libs instead (I've found no variable to use here). OTOH, testsuite_flags.in already hardcodes .libs, so this is a preexisting problem. * I haven't checked if the PIC drt*.o files are actually installed, otherwise gdc wouldn't be able to create shared objects on Solaris. * This comment is misleading now that those files are used unconditionally: # Provide __start_minfo, __stop_minfo if linker doesn't. DRTSTUFF = gcc/drtbegin.o gcc/drtend.o At least with this incremental patch, I've been able to successfully bootstrap and test trunk on i386-pc-solaris2.11 (Solaris 11.3 which lacks ld support for __start_
/__stop_