Skip to content

Commit

Permalink
Fix thread flags on Solaris
Browse files Browse the repository at this point in the history
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
(e165859) 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.
  • Loading branch information
ry committed Mar 31, 2010
1 parent d52f63d commit 4279725
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
8 changes: 4 additions & 4 deletions deps/coupling/coupling.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
21 changes: 13 additions & 8 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]:
Expand All @@ -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')

Expand Down

0 comments on commit 4279725

Please sign in to comment.