From 610dc28a6c858748c6a22ce4478eeaef66477514 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sat, 16 Jan 2016 09:33:39 -0500 Subject: Tweaking discovery of Pthreads C flags --- m4/m4_ax_pthread.m4 | 12 ++++++++++++ src/compiler.sml | 11 ++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/m4/m4_ax_pthread.m4 b/m4/m4_ax_pthread.m4 index d383ad5c..f0717ada 100644 --- a/m4/m4_ax_pthread.m4 +++ b/m4/m4_ax_pthread.m4 @@ -204,11 +204,22 @@ for flag in $ax_pthread_flags; do ;; esac + save_LDFLAGS="$LDFLAGS" save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags" + # This check added by Adam Chlipala on January 16, 2016. + # The documentation at the top of this file said that PTHREAD_CFLAGS needs to + # be used at link-time, too, but this test didn't seem to do so. + # For now, I'm patching just for the common case of '-pthread'. + case $flag in + -pthread) + LDFLAGS="$LDFLAGS -pthread" + ;; + esac + # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) @@ -230,6 +241,7 @@ for flag in $ax_pthread_flags; do [ax_pthread_ok=yes], []) + LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" diff --git a/src/compiler.sml b/src/compiler.sml index e2dc168e..e269c8b9 100644 --- a/src/compiler.sml +++ b/src/compiler.sml @@ -1520,7 +1520,16 @@ fun compileC {cname, oname, ename, libs, profile, debug, linker, link = link'} = ^ " " ^ #compile proto ^ " -c " ^ escapeFilename cname ^ " -o " ^ escapeFilename oname - val linker = Option.getOpt (linker, (Settings.getCCompiler ()) ^ " -Werror" ^ opt ^ " " ^ Config.ccArgs ^ " " ^ Config.pthreadLibs) + fun concatArgs (a1, a2) = + if CharVector.all Char.isSpace a1 then + a2 + else + a1 ^ " " ^ a2 + + val args = concatArgs (Config.ccArgs, Config.pthreadCflags) + val args = concatArgs (args, Config.pthreadLibs) + + val linker = Option.getOpt (linker, (Settings.getCCompiler ()) ^ " -Werror" ^ opt ^ " " ^ args) val ssl = if Settings.getStaticLinking () then Config.openssl ^ " -ldl -lz" -- cgit v1.2.3