From 4279725d790b5b23e89e4ff90cff2c03be21635d Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 31 Mar 2010 13:36:20 -0700 Subject: [PATCH] Fix thread flags on Solaris Also on other platforms use -pthread for compiling commands not just linking because I noticed in the gcc(1) man page -pthread Adds support for multithreading with the pthreads library. This option sets flags for both the preprocessor and linker. Removing the errno check in deps/coupling because it was a hack (e165859c2ebc08b3a00adf4d99003c50ae9936ab) added to fix stdio problems. Without adding -threads, errno is not thread local, and coupling was not correctly checking the errno. It appears -mt does nothing to gcc/solaris. --- deps/coupling/coupling.c | 8 ++++---- wscript | 21 +++++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/deps/coupling/coupling.c b/deps/coupling/coupling.c index 1acc9a90b0..0baa8f3542 100644 --- a/deps/coupling/coupling.c +++ b/deps/coupling/coupling.c @@ -180,7 +180,7 @@ pull_pump (int pullfd, int pushfd) /* eof */ close(pullfd); pullfd = -1; - } else if (r < 0 && errno && errno != EINTR && errno != EAGAIN) { + } else if (r < 0 && errno != EINTR && errno != EAGAIN) { /* error */ perror("pull_pump read()"); close(pullfd); @@ -192,7 +192,7 @@ pull_pump (int pullfd, int pushfd) /* non-blocking write() to the pipe */ r = ring_buffer_push(&ring, pushfd); - if (r < 0 && errno && errno != EAGAIN && errno != EINTR) { + if (r < 0 && errno != EAGAIN && errno != EINTR) { if (errno == EPIPE) { /* This happens if someone closes the other end of the pipe. This * is a normal forced close of STDIN. Hopefully there wasn't data @@ -274,7 +274,7 @@ push_pump (int pullfd, int pushfd) /* eof */ close(pullfd); pullfd = -1; - } else if (r < 0 && errno && errno != EINTR && errno != EAGAIN) { + } else if (r < 0 && errno != EINTR && errno != EAGAIN) { perror("push_pump read()"); close(pullfd); pullfd = -1; @@ -288,7 +288,7 @@ push_pump (int pullfd, int pushfd) /* If there was a problem, just exit the entire function */ - if (r < 0 && errno && errno != EINTR && errno != EAGAIN) { + if (r < 0 && errno != EINTR && errno != EAGAIN) { close(pushfd); close(pullfd); pushfd = pullfd = -1; diff --git a/wscript b/wscript index cbbd16bcc4..aa1be93036 100644 --- a/wscript +++ b/wscript @@ -168,6 +168,16 @@ 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') + else: + threadflags='-pthread' + conf.env.append_value ('CCFLAGS', threadflags) + conf.env.append_value ('CXXFLAGS', threadflags) + conf.env.append_value ('LINKFLAGS', threadflags) + conf.env.append_value("CCFLAGS", "-DX_STACKSIZE=%d" % (1024*64)) # LFS @@ -272,10 +282,8 @@ def build_v8(bld): v8.uselib = "EXECINFO" bld.env["CPPPATH_V8"] = "deps/v8/include" t = join(bld.srcnode.abspath(bld.env_of_name("default")), v8.target) - if sys.platform.startswith("sunos"): - bld.env_of_name('default')["LINKFLAGS_V8"] = ["-mt", t] - else: - bld.env_of_name('default')["LINKFLAGS_V8"] = ["-pthread", t] + bld.env_of_name('default').append_value("LINKFLAGS_V8", t) + ### v8 debug if bld.env["USE_DEBUG"]: @@ -284,10 +292,7 @@ def build_v8(bld): v8_debug.target = bld.env["staticlib_PATTERN"] % "v8_g" v8_debug.uselib = "EXECINFO" t = join(bld.srcnode.abspath(bld.env_of_name("debug")), v8_debug.target) - if sys.platform.startswith("sunos"): - bld.env_of_name('debug')["LINKFLAGS_V8"] = ["-mt", t] - else: - bld.env_of_name('debug')["LINKFLAGS_V8"] = ["-pthread", t] + bld.env_of_name('debug').append_value("LINKFLAGS_V8", t) bld.install_files('${PREFIX}/include/node/', 'deps/v8/include/*.h')