From ced2087998a5439d91f8b671d906b510cb8f7a56 Mon Sep 17 00:00:00 2001 From: Todd Lipcon Date: Thu, 9 Aug 2012 21:58:29 +0000 Subject: [PATCH] HADOOP-8659. Native libraries must build with soft-float ABI for Oracle JVM on ARM. Contributed by Trevor Robinson. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1371508 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop-common/CHANGES.txt | 3 + .../hadoop-common/src/CMakeLists.txt | 13 +--- .../hadoop-common/src/JNIFlags.cmake | 65 +++++++++++++++++++ .../hadoop-hdfs/src/CMakeLists.txt | 13 +--- hadoop-tools/hadoop-pipes/src/CMakeLists.txt | 13 +--- .../src/CMakeLists.txt | 11 +--- 6 files changed, 72 insertions(+), 46 deletions(-) create mode 100644 hadoop-common-project/hadoop-common/src/JNIFlags.cmake diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 3d1296295f3..50c06ffb277 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -176,6 +176,9 @@ Release 2.0.1-alpha - UNRELEASED HADOOP-8480. The native build should honor -DskipTests. (Colin Patrick McCabe via eli) + HADOOP-8659. Native libraries must build with soft-float ABI for Oracle JVM + on ARM. (Trevor Robinson via todd) + BREAKDOWN OF HDFS-3042 SUBTASKS HADOOP-8220. ZKFailoverController doesn't handle failure to become active diff --git a/hadoop-common-project/hadoop-common/src/CMakeLists.txt b/hadoop-common-project/hadoop-common/src/CMakeLists.txt index 129bea34ae2..8ff2f12e6d2 100644 --- a/hadoop-common-project/hadoop-common/src/CMakeLists.txt +++ b/hadoop-common-project/hadoop-common/src/CMakeLists.txt @@ -21,18 +21,7 @@ cmake_minimum_required(VERSION 2.6 FATAL_ERROR) # Default to release builds set(CMAKE_BUILD_TYPE, Release) -# If JVM_ARCH_DATA_MODEL is 32, compile all binaries as 32-bit. -# This variable is set by maven. -if (JVM_ARCH_DATA_MODEL EQUAL 32) - # force 32-bit code generation on amd64/x86_64, ppc64, sparc64 - if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_SYSTEM_PROCESSOR MATCHES ".*64") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") - set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -m32") - endif () - if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") - set(CMAKE_SYSTEM_PROCESSOR "i686") - endif () -endif (JVM_ARCH_DATA_MODEL EQUAL 32) +include(JNIFlags.cmake NO_POLICY_SCOPE) # Compile a library with both shared and static variants function(add_dual_library LIBNAME) diff --git a/hadoop-common-project/hadoop-common/src/JNIFlags.cmake b/hadoop-common-project/hadoop-common/src/JNIFlags.cmake new file mode 100644 index 00000000000..52c3c8ec4cc --- /dev/null +++ b/hadoop-common-project/hadoop-common/src/JNIFlags.cmake @@ -0,0 +1,65 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +cmake_minimum_required(VERSION 2.6 FATAL_ERROR) + +find_package(JNI REQUIRED) + +# If JVM_ARCH_DATA_MODEL is 32, compile all binaries as 32-bit. +# This variable is set by maven. +if (JVM_ARCH_DATA_MODEL EQUAL 32) + # Force 32-bit code generation on amd64/x86_64, ppc64, sparc64 + if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_SYSTEM_PROCESSOR MATCHES ".*64") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -m32") + endif () + if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") + set(CMAKE_SYSTEM_PROCESSOR "i686") + endif () +endif (JVM_ARCH_DATA_MODEL EQUAL 32) + +# Determine float ABI of JVM on ARM Linux +if (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") + find_program(READELF readelf) + if (READELF MATCHES "NOTFOUND") + message(WARNING "readelf not found; JVM float ABI detection disabled") + else (READELF MATCHES "NOTFOUND") + execute_process( + COMMAND ${READELF} -A ${JAVA_JVM_LIBRARY} + OUTPUT_VARIABLE JVM_ELF_ARCH + ERROR_QUIET) + if (NOT JVM_ELF_ARCH MATCHES "Tag_ABI_VFP_args: VFP registers") + message("Soft-float JVM detected") + + # Test compilation with -mfloat-abi=softfp using an arbitrary libc function + # (typically fails with "fatal error: bits/predefs.h: No such file or directory" + # if soft-float dev libraries are not installed) + include(CMakePushCheckState) + cmake_push_check_state() + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mfloat-abi=softfp") + include(CheckSymbolExists) + check_symbol_exists(exit stdlib.h SOFTFP_AVAILABLE) + if (NOT SOFTFP_AVAILABLE) + message(FATAL_ERROR "Soft-float dev libraries required (e.g. 'apt-get install libc6-dev-armel' on Debian/Ubuntu)") + endif (NOT SOFTFP_AVAILABLE) + cmake_pop_check_state() + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=softfp") + endif () + endif (READELF MATCHES "NOTFOUND") +endif (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs/src/CMakeLists.txt index b9a6aa71eec..2239f5d1122 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/src/CMakeLists.txt @@ -21,18 +21,7 @@ cmake_minimum_required(VERSION 2.6 FATAL_ERROR) # Default to release builds set(CMAKE_BUILD_TYPE, Release) -# If JVM_ARCH_DATA_MODEL is 32, compile all binaries as 32-bit. -# This variable is set by maven. -if (JVM_ARCH_DATA_MODEL EQUAL 32) - # force 32-bit code generation on amd64/x86_64, ppc64, sparc64 - if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_SYSTEM_PROCESSOR MATCHES ".*64") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") - set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -m32") - endif () - if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") - set(CMAKE_SYSTEM_PROCESSOR "i686") - endif () -endif (JVM_ARCH_DATA_MODEL EQUAL 32) +include(../../../hadoop-common-project/hadoop-common/src/JNIFlags.cmake NO_POLICY_SCOPE) # Compile a library with both shared and static variants function(add_dual_library LIBNAME) diff --git a/hadoop-tools/hadoop-pipes/src/CMakeLists.txt b/hadoop-tools/hadoop-pipes/src/CMakeLists.txt index a18022f8689..a1ee97daefc 100644 --- a/hadoop-tools/hadoop-pipes/src/CMakeLists.txt +++ b/hadoop-tools/hadoop-pipes/src/CMakeLists.txt @@ -26,17 +26,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -O2") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_REENTRANT -D_FILE_OFFSET_BITS=64") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_REENTRANT -D_FILE_OFFSET_BITS=64") -if (JVM_ARCH_DATA_MODEL EQUAL 32) - # force 32-bit code generation on amd64/x86_64, ppc64, sparc64 - if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_SYSTEM_PROCESSOR MATCHES ".*64") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") - set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -m32") - endif () - if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") - set(CMAKE_SYSTEM_PROCESSOR "i686") - endif () -endif (JVM_ARCH_DATA_MODEL EQUAL 32) +include(../../../hadoop-common-project/hadoop-common/src/JNIFlags.cmake NO_POLICY_SCOPE) function(output_directory TGT DIR) SET_TARGET_PROPERTIES(${TGT} PROPERTIES @@ -80,7 +70,6 @@ add_library(hadooppipes STATIC main/native/pipes/impl/HadoopPipes.cc ) target_link_libraries(hadooppipes - ${JAVA_JVM_LIBRARY} ${OPENSSL_LIBRARIES} pthread ) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/CMakeLists.txt b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/CMakeLists.txt index ce6151fc846..d69b845249f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/CMakeLists.txt +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/CMakeLists.txt @@ -18,16 +18,7 @@ cmake_minimum_required(VERSION 2.6 FATAL_ERROR) set(CMAKE_BUILD_TYPE, Release) -if (JVM_ARCH_DATA_MODEL EQUAL 32) - # force 32-bit code generation on amd64/x86_64, ppc64, sparc64 - if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_SYSTEM_PROCESSOR MATCHES ".*64") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") - set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -m32") - endif () - if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") - set(CMAKE_SYSTEM_PROCESSOR "i686") - endif () -endif (JVM_ARCH_DATA_MODEL EQUAL 32) +include(../../../../../hadoop-common-project/hadoop-common/src/JNIFlags.cmake NO_POLICY_SCOPE) function(output_directory TGT DIR) SET_TARGET_PROPERTIES(${TGT} PROPERTIES