Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix build with gcc 4.7.0 on sunos: use -pthreads #4211

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

trentm commented Oct 29, 2012

Specifically I'm testing on a recent smartos. With this recent gcc
version at least the "-threads" option is an HPPA-only option. The use
of '-threads' for sunos builds dates back to
4279725

I know that a new v0.4 build isn't planned, but this would help those stuck deploying old v0.4-only services to a new sunos box.

@trentm trentm Fix build with gcc 4.7.0 on sunos: use -pthreads
Specifically I'm testing on a recent smartos.  With this recent gcc
version at least the "-threads" option is an HPPA-only option. The use
of '-threads' for sunos builds dates back to
4279725
ceac05d

@bnoordhuis bnoordhuis commented on the diff Oct 30, 2012

@@ -424,11 +424,7 @@ def configure(conf):
conf.define("HAVE_CONFIG_H", 1)
- if sys.platform.startswith("sunos"):
- conf.env.append_value ('CCFLAGS', '-threads')
- conf.env.append_value ('CXXFLAGS', '-threads')
- #conf.env.append_value ('LINKFLAGS', ' -threads')
- elif not sys.platform.startswith("cygwin") and not sys.platform.startswith("win32"):
+ if not sys.platform.startswith("cygwin") and not sys.platform.startswith("win32"):
threadflags='-pthread'
@bnoordhuis

bnoordhuis Oct 30, 2012

Owner

Does this actually work? I thought the thing with gcc on sunos is that you need to specify -pthreads instead of -pthread?

@trentm

trentm Oct 30, 2012

Yes, works for me: https://gist.github.com/3977987

Also man gcc has this:

       These switches are supported in addition to the above on Solaris 2:

       -pthreads
           Add support for multithreading using the POSIX threads library.
           This option sets flags for both the preprocessor and linker.  This
           option does not affect the thread safety of object code produced
           by the compiler or that of libraries supplied with it.

       -pthread
           This is a synonym for -pthreads.
@bnoordhuis

bnoordhuis Oct 30, 2012

Owner

Okay, I did some digging and it turns out that -pthread was added as an alias for -pthreads in 4.2 (gcc-mirror/gcc@4207fff). Now, I don't mind landing this patch but I recall that some machines at Joyent still have gcc 3.4 as the default compiler - on those machines, the build will be broken.

@trentm

trentm Oct 30, 2012

Thanks for digging into that. How about this patch instead

diff --git a/wscript b/wscript
index eab6990..7a93707 100644
--- a/wscript
+++ b/wscript
@@ -425,9 +425,12 @@ def configure(conf):
   conf.define("HAVE_CONFIG_H", 1)

   if sys.platform.startswith("sunos"):
-    conf.env.append_value ('CCFLAGS', '-threads')
-    conf.env.append_value ('CXXFLAGS', '-threads')
-    #conf.env.append_value ('LINKFLAGS', ' -threads')
+    # In gcc 4.2 '-pthread' was added as an alias for '-pthreads'. We use
+    # '-pthreads' to not break older gcc versions.
+    threadflags='-pthreads'
+    conf.env.append_value ('CCFLAGS', threadflags)
+    conf.env.append_value ('CXXFLAGS', threadflags)
+    conf.env.append_value ('LINKFLAGS', threadflags)
   elif not sys.platform.startswith("cygwin") and not sys.platform.startswith("win32"):
     threadflags='-pthread'
     conf.env.append_value ('CCFLAGS', threadflags)

?

@bnoordhuis

bnoordhuis Oct 30, 2012

Owner

LGTM. Landed in 1f4e0c0 - exactly one year after the last commit. :-)

@trentm trentm closed this in 1f4e0c0 Oct 30, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment