Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
wants to merge 1 commit into from

2 participants

@trentm
Owner

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
joyent@4279725
ceac05d
@bnoordhuis bnoordhuis commented on the diff
@@ -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'

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

@trentm Owner
trentm added a note

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.

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 Owner
trentm added a note

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)

?

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

@trentm Owner
trentm added a note

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@trentm trentm closed this pull request from a commit
@trentm trentm build: fix gcc 4.7 sunos build
gcc 4.7 doesn't understand -threads, use -pthreads instead.

Fixes #4211.
1f4e0c0
@trentm trentm closed this in 1f4e0c0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 29, 2012
  1. @trentm

    Fix build with gcc 4.7.0 on sunos: use -pthreads

    trentm authored
    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
    joyent@4279725
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 5 deletions.
  1. +1 −5 wscript
View
6 wscript
@@ -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'

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

@trentm Owner
trentm added a note

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.

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 Owner
trentm added a note

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)

?

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

@trentm Owner
trentm added a note

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
conf.env.append_value ('CCFLAGS', threadflags)
conf.env.append_value ('CXXFLAGS', threadflags)
Something went wrong with that request. Please try again.