summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2016-01-16 09:33:39 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2016-01-16 09:33:39 -0500
commit610dc28a6c858748c6a22ce4478eeaef66477514 (patch)
tree58470b0e06f254a547e58896dd07bf272e0c312a
parentd47ffbc86c1cafb041588ab0ea7540c538196cb9 (diff)
Tweaking discovery of Pthreads C flags
-rw-r--r--m4/m4_ax_pthread.m412
-rw-r--r--src/compiler.sml11
2 files changed, 22 insertions, 1 deletions
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"