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");
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
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
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
@ -158,21 +159,25 @@
<execution>
<id>make</id>
<phase>compile</phase>
<goals><goal>run</goal></goals>
<goals>
<goal>run</goal>
</goals>
<configuration>
<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" />
</copy>
<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}" />
</exec>
<exec executable="make" dir="${project.build.directory}/native" failonerror="true">
<arg line="VERBOSE=1" />
</exec>
<!-- The second make is a workaround for HADOOP-9215. It can
be removed when version 2.6 of cmake is no longer supported . -->
<!-- The second make is a workaround for HADOOP-9215. It can be
removed when version 2.6 of cmake is no longer supported . -->
<exec executable="make" dir="${project.build.directory}/native" failonerror="true"></exec>
</target>
</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)
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
${D}/lz4/lz4.c
${D}/cityhash/city.cc
@ -208,15 +215,8 @@ add_dual_library(nativetask
${D}/src/util/Timer.cc
${D}/src/util/WritableUtils.cc
)
target_link_libraries(nativetask
#${LIB_DL}
dl
rt
pthread
z
${SNAPPY_LIBRARY}
${JAVA_JVM_LIBRARY}
)
target_link_libraries(nativetask ${NT_DEPEND_LIBRARY})
add_executable(nttest
${D}/gtest/gtest-all.cc
@ -249,19 +249,17 @@ add_executable(nttest
${D}/test/TestSort.cc
${D}/test/TestMain.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
nativetask_static
dl
rt
pthread
z
${SNAPPY_LIBRARY}
# ${JAVA_JVM_LIBRARY}
${NT_DEPEND_LIBRARY}
)
#if (NEED_LINK_DL)
# set(LIB_DL dl)
#endif (NEED_LINK_DL)
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
#

View File

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

View File

@ -166,7 +166,7 @@ TEST(Perf, IFile) {
TEST(IFile, TestGlibCBug) {
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());
IFileSegment * segments = new IFileSegment [1];
@ -182,7 +182,8 @@ TEST(IFile, TestGlibCBug) {
reader->nextPartition();
uint32_t index = 0;
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);
index++;
}