drojaazu / sgdk_nix

Makefiles and instructions for using SGDK in *nix environments
MIT License
29 stars 5 forks source link

Added support for m68k compilers configured with --enable-lto etc. #2

Closed evethr closed 4 years ago

evethr commented 4 years ago

I suggest those changes to make better support for some compilers. I was able to set SGDK up using sgdk_nix on Gentoo using m68k-gcc that I got up and running via crossdev. However, there is a difference between m68k-gcc on Arch and on Gentoo. Running Arch m68k-elf-gcc -### yields:

COLLECT_GCC=/mnt/bin/m68k-elf-gcc
COLLECT_LTO_WRAPPER=/mnt/usr/bin/../libexec/gcc/m68k-elf/9.2.0/lto-wrapper
Target: m68k-elf
Configured with: ../gcc-9.2.0/configure --prefix=/usr --target=m68k-elf --enable-languages=c --disable-multilib --with-cpu=m68000 --with-system-zlib --with-libgloss --without-headers --disable-shared --disable-nls
Thread model: single
gcc version 9.2.0 (GCC)

While running Gentoo m68k-unknown-linux-gnu-gcc -### built by crossdev out of the box without any additional tweaking whatsoever yields the following on my machine:

COLLECT_GCC=m68k-unknown-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/m68k-unknown-linux-gnu/10.2.0/lto-wrapper
Target: m68k-unknown-linux-gnu
Configured with: /var/tmp/portage/cross-m68k-unknown-linux-gnu/gcc-10.2.0/work/gcc-10.2.0/configure --host=x86_64-pc-linux-gnu --target=m68k-unknown-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/m68k-unknown-linux-gnu/gcc-bin/10.2.0 --includedir=/usr/lib/gcc/m68k-unknown-linux-gnu/10.2.0/include --datadir=/usr/share/gcc-data/m68k-unknown-linux-gnu/10.2.0 --mandir=/usr/share/gcc-data/m68k-unknown-linux-gnu/10.2.0/man --infodir=/usr/share/gcc-data/m68k-unknown-linux-gnu/10.2.0/info --with-gxx-include-dir=/usr/lib/gcc/m68k-unknown-linux-gnu/10.2.0/include/g++-v10 --with-python-dir=/share/gcc-data/m68k-unknown-linux-gnu/10.2.0/python --enable-languages=c,c++ --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 10.2.0 p1' --disable-esp --enable-libstdcxx-time --enable-poison-system-directories --with-sysroot=/usr/m68k-unknown-linux-gnu --disable-bootstrap --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --disable-fixed-point --enable-libgomp --disable-libssp --disable-libada --disable-systemtap --disable-vtable-verify --disable-libvtv --without-zstd --enable-lto --without-isl --disable-libsanitizer --enable-default-pie --enable-default-ssp
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (Gentoo 10.2.0 p1)

In comparison, the latter has --enable-lto --enable-default-pie --enable-default-ssp, which enables link time optimization, position independent executable and stack smashing protection, which we do not want. Luckily, there is an easy fix to work around that by supplying gcc with -fno-pie -no-pie -fno-stack-protector -fno-lto to revert those default settings back. Of course, those changes should not make any impact on compilers with those settings disabled by default.

evethr commented 4 years ago

sorry, I re-tested this out and it seems that I need some further work other than that