From d14089fb3cef922a0c3a61661fd1c92bd083e991 Mon Sep 17 00:00:00 2001 From: k0kubun Date: Mon, 14 Jan 2019 06:18:53 +0000 Subject: [PATCH] mjit_worker.c: pass -lgcc to GCC platforms using `-nodefaultlibs -nostdlib`. I assume libgcc is needed when we use -nostdlib, and it's linked on some platforms but not linked on some platforms (like aarch64, and possibly AIX as well) as said in https://wiki.osdev.org/Libgcc : > You can link with libgcc by passing -lgcc when linking your kernel with your compiler. You don't need to do this unless you pass the -nodefaultlibs option (implied by -nostdlib) Also note that -nostdlib is not strictly needed (rather implied -nodefaultlibs is problematic for Gentoo like Bug#15513, which will be approached later) but helpful for performance. So I want to keep it for now. [Bug #15522] I'm not trying to add `-nodefaultlibs -nostdlib` for AIX in this commit because AIX RubyCI is dead right now, but I'll try to add them again once RubyCI is fixed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- mjit_worker.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mjit_worker.c b/mjit_worker.c index b69fe1e1bf..e56b454269 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -268,14 +268,14 @@ static const char *const CC_DLDFLAGS_ARGS[] = { }; static const char *const CC_LIBS[] = { -#if defined(_WIN32) || defined(__CYGWIN__) // mswin, mingw, cygwin - MJIT_LIBS +#if defined(_WIN32) || defined(__CYGWIN__) + MJIT_LIBS // mswin, mingw, cygwin #endif -#if defined(_WIN32) && defined __GNUC__ && !defined __clang__ // mingw - "-lmsvcrt", -#endif -#if (defined(_WIN32) || defined(__CYGWIN__)) && defined __GNUC__ && !defined __clang__ // mingw, cygwin - "-lgcc", +#if defined __GNUC__ && !defined __clang__ +# if defined(_WIN32) + "-lmsvcrt", // mingw +# endif + "-lgcc", // mingw, cygwin, and GCC platforms using `-nodefaultlibs -nostdlib` #endif NULL };