MAPREDUCE-5985. native-task: Fix build on macosx. Contributed by Binglin Chang

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/MR-2841@1612659 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Todd Lipcon 2014-07-22 19:55:03 +00:00
parent b2551c06a0
commit e788e8b6ee
5 changed files with 111 additions and 102 deletions

View File

@ -0,0 +1,4 @@
Changes for Hadoop Native Map Output Collector
------------------------------------------------
MAPREDUCE-5985. native-task: Fix build on macosx. Contributed by Binglin Chang

View File

@ -1,4 +1,4 @@
<?xml version="1.0"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -12,7 +12,8 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. See accompanying LICENSE file. limitations under the License. See accompanying LICENSE file.
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"> http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
@ -158,21 +159,25 @@
<execution> <execution>
<id>make</id> <id>make</id>
<phase>compile</phase> <phase>compile</phase>
<goals><goal>run</goal></goals> <goals>
<goal>run</goal>
</goals>
<configuration> <configuration>
<target> <target>
<copy todir="${project.build.directory}/native/test/testData" overwrite="true"> <copy todir="${project.build.directory}/native/test/testData"
overwrite="true">
<fileset dir="${basedir}/src/main/native/testData" /> <fileset dir="${basedir}/src/main/native/testData" />
</copy> </copy>
<copy file="${basedir}/src/main/native/test.sh" todir="${project.build.directory}/native/test" /> <copy file="${basedir}/src/main/native/test.sh" todir="${project.build.directory}/native/test" />
<exec executable="cmake" dir="${project.build.directory}/native" failonerror="true"> <exec executable="cmake" dir="${project.build.directory}/native"
failonerror="true">
<arg line="${basedir}/src/ -DGENERATED_JAVAH=${project.build.directory}/native/javah -DJVM_ARCH_DATA_MODEL=${sun.arch.data.model} -DREQUIRE_SNAPPY=${require.snappy} -DCUSTOM_SNAPPY_PREFIX=${snappy.prefix} -DCUSTOM_SNAPPY_LIB=${snappy.lib} -DCUSTOM_SNAPPY_INCLUDE=${snappy.include}" /> <arg line="${basedir}/src/ -DGENERATED_JAVAH=${project.build.directory}/native/javah -DJVM_ARCH_DATA_MODEL=${sun.arch.data.model} -DREQUIRE_SNAPPY=${require.snappy} -DCUSTOM_SNAPPY_PREFIX=${snappy.prefix} -DCUSTOM_SNAPPY_LIB=${snappy.lib} -DCUSTOM_SNAPPY_INCLUDE=${snappy.include}" />
</exec> </exec>
<exec executable="make" dir="${project.build.directory}/native" failonerror="true"> <exec executable="make" dir="${project.build.directory}/native" failonerror="true">
<arg line="VERBOSE=1" /> <arg line="VERBOSE=1" />
</exec> </exec>
<!-- The second make is a workaround for HADOOP-9215. It can <!-- The second make is a workaround for HADOOP-9215. It can be
be removed when version 2.6 of cmake is no longer supported . --> removed when version 2.6 of cmake is no longer supported . -->
<exec executable="make" dir="${project.build.directory}/native" failonerror="true"></exec> <exec executable="make" dir="${project.build.directory}/native" failonerror="true"></exec>
</target> </target>
</configuration> </configuration>

View File

@ -166,6 +166,13 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# macosx does not have -lrt
set(NT_DEPEND_LIBRARY dl pthread z ${SNAPPY_LIBRARY} ${JAVA_JVM_LIBRARY})
else (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(NT_DEPEND_LIBRARY dl rt pthread z ${SNAPPY_LIBRARY} ${JAVA_JVM_LIBRARY})
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_dual_library(nativetask add_dual_library(nativetask
${D}/lz4/lz4.c ${D}/lz4/lz4.c
${D}/cityhash/city.cc ${D}/cityhash/city.cc
@ -208,15 +215,8 @@ add_dual_library(nativetask
${D}/src/util/Timer.cc ${D}/src/util/Timer.cc
${D}/src/util/WritableUtils.cc ${D}/src/util/WritableUtils.cc
) )
target_link_libraries(nativetask
#${LIB_DL} target_link_libraries(nativetask ${NT_DEPEND_LIBRARY})
dl
rt
pthread
z
${SNAPPY_LIBRARY}
${JAVA_JVM_LIBRARY}
)
add_executable(nttest add_executable(nttest
${D}/gtest/gtest-all.cc ${D}/gtest/gtest-all.cc
@ -249,19 +249,17 @@ add_executable(nttest
${D}/test/TestSort.cc ${D}/test/TestSort.cc
${D}/test/TestMain.cc ${D}/test/TestMain.cc
${D}/test/test_commons.cc) ${D}/test/test_commons.cc)
set(CMAKE_EXE_LINKER_FLAGS "-L${_JAVA_HOME}/jre/lib/amd64/server -ljvm")
IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# macos clang with libc++ does not have tr1/tuple, just tuple
SET_TARGET_PROPERTIES(nttest PROPERTIES COMPILE_FLAGS "-DGTEST_USE_OWN_TR1_TUPLE=1")
ENDIF()
target_link_libraries(nttest target_link_libraries(nttest
nativetask_static nativetask_static
dl ${NT_DEPEND_LIBRARY}
rt
pthread
z
${SNAPPY_LIBRARY}
# ${JAVA_JVM_LIBRARY}
) )
#if (NEED_LINK_DL)
# set(LIB_DL dl)
#endif (NEED_LINK_DL)
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# #

View File

@ -25,6 +25,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <memory.h> #include <memory.h>
#include <fcntl.h> #include <fcntl.h>

View File

@ -166,7 +166,7 @@ TEST(Perf, IFile) {
TEST(IFile, TestGlibCBug) { TEST(IFile, TestGlibCBug) {
std::string path("./testData/testGlibCBugSpill.out"); std::string path("./testData/testGlibCBugSpill.out");
uint32_t expect[5] = {-1538241715, -1288088794, -192294464, 563552421, 1661521654}; int32_t expect[5] = {-1538241715, -1288088794, -192294464, 563552421, 1661521654};
LOG("TestGlibCBug %s", path.c_str()); LOG("TestGlibCBug %s", path.c_str());
IFileSegment * segments = new IFileSegment [1]; IFileSegment * segments = new IFileSegment [1];
@ -182,7 +182,8 @@ TEST(IFile, TestGlibCBug) {
reader->nextPartition(); reader->nextPartition();
uint32_t index = 0; uint32_t index = 0;
while(NULL != (key = reader->nextKey(length))) { while(NULL != (key = reader->nextKey(length))) {
int realKey = bswap(*(uint32_t *)(key)); int32_t realKey = (int32_t)bswap(*(uint32_t *)(key));
ASSERT_LT(index, 5);
ASSERT_EQ(expect[index], realKey); ASSERT_EQ(expect[index], realKey);
index++; index++;
} }