[ 
https://issues.apache.org/jira/browse/HADOOP-8569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13415584#comment-13415584
 ] 

Andy Isaacson commented on HADOOP-8569:
---------------------------------------

The downside to defining {{_GNU_SOURCE}} everywhere -- in both code that is 
known to need it, and in code that is intended to be portable -- is that it 
makes it very easy to accidentally break compilation on non-GNU platforms by 
unintentionally changing code from "portable" to "gnu-specific".  Suppose we 
have a project with {{foo-linux.c}} containing nonportable code, and 
{{generic.c}} containing POSIX portable code.  If I define {{_GNU_SOURCE}} in 
{{CFLAGS}} then unintentionally adding a call to {{sync_file_range}} to 
{{generic.c}} will silently work on Linux, and won't break the build until you 
try building on Darwin or Solaris or whatever.

If instead the project puts {{#define _GNU_SOURCE}} at the top of files 
intended to be platform-specific, then such portability breakage will be 
noticed immediately.

The argument doesn't extend to LFS support -- it's entirely reasonable to use 
64-bit-{{off_t}} everywhere including Linux-32.

{code}
+# note: can't enable -D_FILE_OFFSET_BITS=64: see MAPREDUCE-4258
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_REENTRANT -D_GNU_SOURCE")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE")
{code}
If we don't have FILE_OFFSET_BITS=64, then shouldn't we also leave out 
LARGEFILE_SOURCE?  (This is a serious question, I don't know how those two 
defines interact, I just vaguely remember that there's a complicated rule about 
how they should be used.)

In summary -- I'd slightly prefer to limit the GNU_SOURCE to a {{#define}} in 
the files that we intend to be Linux-specific.  The rest of this patch is good 
though, cleaning up the LFS defines and adding that comment about 
MAPREDUCE-4258.
                
> CMakeLists.txt: define _GNU_SOURCE and _LARGEFILE_SOURCE
> --------------------------------------------------------
>
>                 Key: HADOOP-8569
>                 URL: https://issues.apache.org/jira/browse/HADOOP-8569
>             Project: Hadoop Common
>          Issue Type: Bug
>            Reporter: Colin Patrick McCabe
>            Assignee: Colin Patrick McCabe
>            Priority: Minor
>         Attachments: HADOOP-8569.001.patch
>
>
> In the native code, we should define _GNU_SOURCE and _LARGEFILE_SOURCE so 
> that all of the functions on Linux are available.
> _LARGEFILE enables fseeko and ftello; _GNU_SOURCE enables a variety of 
> Linux-specific functions from glibc, including sync_file_range.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to