Permalink
Browse files

build: export _POSIX_C_SOURCE=200112 to dependents

Fix direct_dependent_settings to export _POSIX_C_SOURCE=200112 to dependent
projects. Required to make pthread_rwlock_t and pthread_barrier_t visible.
  • Loading branch information...
1 parent 0820be7 commit 6fb31493d76381bd0e597400da65cbfd33b89ff9 @bnoordhuis bnoordhuis committed Dec 19, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 uv.gyp
View
6 uv.gyp
@@ -31,7 +31,11 @@
'include_dirs': [ 'include' ],
'conditions': [
['OS != "win"', {
- 'defines': [ '_LARGEFILE_SOURCE', '_FILE_OFFSET_BITS=64' ],
+ 'defines': [
+ '_LARGEFILE_SOURCE',
+ '_FILE_OFFSET_BITS=64',
+ '_POSIX_C_SOURCE=200112',
+ ],
}],
['OS == "mac"', {
'defines': [ '_DARWIN_USE_64_BIT_INODE=1' ],

6 comments on commit 6fb3149

@ttilley

macos contains a significant number (~380 on mountain lion) of preprocessor checks to the effect of:

#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)

Defining _POSIX_C_SOURCE on darwin breaks the test suite due to some missing compatibility defines at the least and quite possibly results in subtle brokenness elsewhere that just isn't as obvious.

Rather than make the criteria for when _POSIX_C_SOURCE is defined more specific, I think it would probably be safer to keep the define unix-global and just ensure that _DARWIN_C_SOURCE is also defined on mac. That'd keep things consistent at least.

@bnoordhuis

Rather than make the criteria for when _POSIX_C_SOURCE is defined more specific, I think it would probably be safer to keep the define unix-global and just ensure that _DARWIN_C_SOURCE is also defined on mac. That'd keep things consistent at least.

That sounds reasonable. Can you post the build errors you got? I can't check it myself right now, I returned my MBP.

@ttilley

I believe the first error I got was directly related to this header snippet:

#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
#define S_ISTXT         S_ISVTX         /* sticky bit: not supported */
#define S_IREAD         S_IRUSR         /* backward compatability */
#define S_IWRITE        S_IWUSR         /* backward compatability */
#define S_IEXEC         S_IXUSR         /* backward compatability */
#endif

where test-fs.c contains code such as:

  r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT,
      S_IREAD | S_IWRITE, create_cb);

which will fail without S_IREAD or S_IWRITE being defined.

@bnoordhuis

Okay, noted. Does this patch fix it?

diff --git a/uv.gyp b/uv.gyp
index 3e0b229..da72bc2 100644
--- a/uv.gyp
+++ b/uv.gyp
@@ -38,7 +38,10 @@
             ],
           }],
           ['OS == "mac"', {
-            'defines': [ '_DARWIN_USE_64_BIT_INODE=1' ],
+            'defines': [
+              '_DARWIN_USE_64_BIT_INODE=1',
+              '_DARWIN_C_SOURCE',  # _POSIX_C_SOURCE hides sysv7 definitions.
+            ],
           }],
         ],
       },
@ttilley

builds with test failures for process_title (unimplemented, so expected), pipe_connect_to_file, fs_event_watch_file_twice, and fs_readdir_file. These are all unrelated and the same set that fail before the commit for defining _POSIX_C_SOURCE.

The non-gyp build, however, passes all tests except for the one unimplemented feature. In any case, that's a discussion best suited to the issues system than comments on an unrelated commit. ;)

EDIT: I ramble. In short, that's a "yes".
EDIT2: some of that gyp weirdness may be due to gyp trunk defining ARCHS as ['i386'] regardless of what you set for target_arch. this will require the addition of a conditional in the xcode_settings that properly sets ARCHS based on the value of target_arch. 💢

@bnoordhuis

Thanks for testing, applied in 495ac83.

EDIT2: some of that gyp weirdness may be due to gyp trunk defining ARCHS as ['i386'] regardless of what you set for target_arch. this will require the addition of a conditional in the xcode_settings that properly sets ARCHS based on the value of target_arch.

That sounds plausible, I remember fixing that in node.js. Does this patch help?

diff --git a/common.gypi b/common.gypi
index 0a60249..ed60347 100644
--- a/common.gypi
+++ b/common.gypi
@@ -173,6 +173,12 @@
           ],
         },
         'target_conditions': [
+          ['target_arch=="ia32"', {
+            'xcode_settings': {'ARCHS': ['i386']},
+          }],
+          ['target_arch=="x64"', {
+            'xcode_settings': {'ARCHS': ['x86_64']},
+          }],
           ['_type!="static_library"', {
             'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
           }],
Please sign in to comment.