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

Alan Burlison commented on HADOOP-11997:
----------------------------------------

I agree that setting _GNU_SOURCE as needed in specific source files is less of 
an issue, although use of Linux-only features inevitably means such code is 
non-portable, which is why I said I believed platform-neutral alternatives 
should also be provided in such cases. The problem is that _GNU_SOURCE is being 
set globally for *all* source which means that developers can inadvertently use 
Linux-only features and not realise they have done so. Requiring explicit 
#define _GNU_SOURCE in source files makes it clear where Linux-only features 
are being used and makes it easier for people supporting other platforms to 
find them. I'm not saying that platform-specific features should not be used, I 
am saying that making the assumption that Linux-only APIs are always available 
is incorrect, and if we can catch that at compile-time then that would seem to 
be a good thing.

As far as I can tell, CMake already sets debugging/optimisation flags based on 
the value of CMAKE_BUILD_TYPE, my concern was that the direct assignment would 
conflict with that, if that's not an issue when your explanation of why the 
flags are as they are makes good sense.

The largefile flags comment was just that - sorry I should have made that 
clearer - the flags are unnecessary for LP64 builds but cause no harm and can 
just be left.

As for not setting _GNU_SOURCE on Solaris, how will that help? Linux-specific 
code wont compile in either case.

> CMake CMAKE_C_FLAGS are non-portable
> ------------------------------------
>
>                 Key: HADOOP-11997
>                 URL: https://issues.apache.org/jira/browse/HADOOP-11997
>             Project: Hadoop Common
>          Issue Type: Sub-task
>          Components: build
>    Affects Versions: 2.7.0
>         Environment: All
>            Reporter: Alan Burlison
>            Assignee: Alan Burlison
>            Priority: Critical
>
> hadoop-common-project/hadoop-common/src/CMakeLists.txt 
> (https://github.com/apache/hadoop/blob/trunk/hadoop-common-project/hadoop-common/src/CMakeLists.txt#L110)
>  contains the following unconditional assignments to CMAKE_C_FLAGS:
> set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -O2")
> set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_REENTRANT -D_GNU_SOURCE")
> set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE 
> -D_FILE_OFFSET_BITS=64")
> There are several issues here:
> 1. "-D_GNU_SOURCE" globally enables the use of all Linux-only extensions in 
> hadoop-common native source. This is probably a major contributor to the poor 
> cross-platform portability of Hadoop native code to non-Linux platforms as it 
> makes it easy for developers to use non-portable Linux features without 
> realising. Use of Linux-specific features should be correctly bracketed with 
> conditional macro blocks that provide an alternative for non-Linux platforms.
> 2. "-g -Wall -O2" turns on debugging for all builds, I believe the correct 
> mechanism is to set the CMAKE_BUILD_TYPE CMake variable. If it is still 
> necessary to override CFLAGS it should probably be done conditionally 
> dependent on the value of CMAKE_BUILD_TYPE.
> 3. "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" On Solaris these flags are 
> only needed for largefile support in ILP32 applications, LP64 applications 
> are largefile by default. I believe the same is true on Linux, so these flags 
> are harmless but redundant for 64-bit compilation.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to