Squashed commit of the following:

commit 931d3de6c1c903cfd47842bc5026a9294ac492b4
Author: Siu Chi Chan <siuchi.chan@amd.com>
Date:   Mon Feb 13 10:54:06 2017 -0500

    only force to libstdc++ if the g++ is older than version 5 since hcc already defaults to libstdc++ with newer g++

commit 1ef8d71aa788de7b9eead4906fe56186f06d7d3f
Author: scchan <siuchi.chan@amd.com>
Date:   Sun Feb 12 14:44:11 2017 -0500

    remove hardcoded -lc++ in tests

commit 5d99ef338eb3a66523cc9ddd139e86c6fd707b9c
Author: scchan <siuchi.chan@amd.com>
Date:   Sun Feb 12 14:35:46 2017 -0500

    force include libstdc++ headers and stdc++ only if g++ version < 5 since hcc uses libstdc++ by default if g++ > 5 is present

commit a2bc21b24d100feefe91cd3cb2271238bda0738a
Author: scchan <siuchi.chan@amd.com>
Date:   Fri Feb 10 04:36:27 2017 -0500

    use hcc-config to generate compiler and linker flags

Change-Id: I13a79629c0adfd75439a47d0488ff4fd619c55ba
(cherry picked from commit 866e744e40cf1378af8a679b54959bf5226c340f)
This commit is contained in:
Siu Chi Chan
2017-02-13 11:50:45 -05:00
committed by Maneesh Gupta
parent 950434f4af
commit 806deeb476
5 changed files with 22 additions and 33 deletions
+6 -4
View File
@@ -158,7 +158,8 @@ if(HIP_PLATFORM STREQUAL "hcc")
set(HIP_HCC_BUILD_FLAGS "${HIP_HCC_BUILD_FLAGS} -DHIP_VERSION_MAJOR=${HIP_VERSION_MAJOR} -DHIP_VERSION_MINOR=${HIP_VERSION_MINOR} -DHIP_VERSION_PATCH=${HIP_VERSION_PATCH}")
# Add remaining flags
set(HIP_HCC_BUILD_FLAGS "${HIP_HCC_BUILD_FLAGS} -fPIC -hc -I${HCC_HOME}/include -I${HSA_PATH}/include -I/opt/rocm/libhsakmt/include -I/usr/local/include/c++/v1 -stdlib=libc++")
execute_process(COMMAND ${HCC_HOME}/bin/hcc-config --cxxflags OUTPUT_VARIABLE HCC_CXX_FLAGS)
set(HIP_HCC_BUILD_FLAGS "${HIP_HCC_BUILD_FLAGS} -fPIC ${HCC_CXX_FLAGS} -I${HSA_PATH}/include -I/opt/rocm/libhsakmt/include")
# Set compiler and compiler flags
set(CMAKE_CXX_COMPILER "${HCC_HOME}/bin/hcc")
@@ -185,12 +186,13 @@ if(HIP_PLATFORM STREQUAL "hcc")
src/device_functions.cpp
src/math_functions.cpp)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${HCC_HOME}/lib -lmcwamp -Wl,-Bsymbolic -Wl,-rpath ${HCC_HOME}/lib")
execute_process(COMMAND ${HCC_HOME}/bin/hcc-config --ldflags OUTPUT_VARIABLE HCC_LD_FLAGS)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${HCC_LD_FLAGS} -Wl,-Bsymbolic")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803")
add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME})
target_link_libraries(hip_hcc c++ c++abi hc_am)
target_link_libraries(hip_hcc hc_am)
add_library(hip_hcc_static STATIC ${SOURCE_FILES_RUNTIME})
target_link_libraries(hip_hcc_static c++ c++abi hc_am)
target_link_libraries(hip_hcc_static hc_am)
add_dependencies(hip_hcc_static hip_hcc)
add_library(hip_device STATIC ${SOURCE_FILES_DEVICE})
add_dependencies(hip_device hip_hcc)
+12 -25
View File
@@ -97,6 +97,8 @@ if ($HIP_PLATFORM eq "hcc") {
$HIPCC=$HCC;
$HIPCXXFLAGS = $HCCFLAGS;
$HIPLDFLAGS = `${HCC_HOME}/bin/hcc-config --ldflags`;
#### GCC system includes workaround ####
$HCC_WA_FLAGS = " ";
if ($HCC_VERSION_MAJOR eq 1) {
@@ -104,34 +106,23 @@ if ($HIP_PLATFORM eq "hcc") {
my $GPP_CUR_VER = `g++ -dumpversion`;
$GCC_CUR_VER =~ s/\R//g;
$GPP_CUR_VER =~ s/\R//g;
if (${GCC_CUR_VER} eq ${GPP_CUR_VER}) {
$HCC_WA_FLAGS .= " -I/usr/include/x86_64-linux-gnu -I/usr/include/x86_64-linux-gnu/c++/${GCC_CUR_VER} -I/usr/include/c++/${GCC_CUR_VER} ";
my @GPP_VER_FIELDS = split('\.', $GPP_CUR_VER);
# Only include the libstdc++ headers and libraries flags explicitly if the g++ is older than version 5.
# That's because HCC already uses libstdc++ by default if a newer g++/libstdc++ is available
if (${GCC_CUR_VER} eq ${GPP_CUR_VER} and $GPP_VER_FIELDS[0] < 5) {
$HCC_WA_FLAGS .= " -stdlib=libstdc++ -I/usr/include/x86_64-linux-gnu -I/usr/include/x86_64-linux-gnu/c++/${GCC_CUR_VER} -I/usr/include/c++/${GCC_CUR_VER} ";
# Add C++ libs for GCC.
$HIPLDFLAGS .= " -lstdc++";
}
}
$HIPCXXFLAGS .= " -I$HIP_PATH/include/hip/hcc_detail/cuda";
$HIPCXXFLAGS .= " -I$HSA_PATH/include";
$HIPCXXFLAGS .= " -Wno-deprecated-register";
$HIPLDFLAGS = "-hc -L$HCC_HOME/lib -Wl,--rpath=$HCC_HOME/lib -lc++ -ldl -lpthread -Wl,--whole-archive -lmcwamp -Wl,--no-whole-archive";
# Suppress linker warnings in case HCC distribution contains OpenCL/SPIR symbols
$HOST_OSNAME= `cat /etc/os-release | grep "^ID\=" | cut -d= -f2 | tr -d '\n'`;
$HOST_OSVER= `cat /etc/os-release | grep "^VERSION_ID\=" | cut -d= -f2 | tr -d '\n'`;
if ($HOST_OSNAME eq "ubuntu" and $HOST_OSVER eq "\"16.04\"") {
# No additional flags required
} else {
$HIPLDFLAGS .= " -Wl,--defsym=_binary_kernel_spir_end=1 -Wl,--defsym=_binary_kernel_spir_start=1 -Wl,--defsym=_binary_kernel_cl_start=1 -Wl,--defsym=_binary_kernel_cl_end=1";
}
if ($HOST_OSNAME eq "fedora") {
$HIPCXXFLAGS .= " -I/usr/local/include/c++/v1";
}
# Satisfy HCC dependencies
if ($HOST_OSNAME eq "fedora") {
$HIPLDFLAGS .= " -lc++abi";
} else {
$HIPLDFLAGS .= " -lc++abi -lsupc++";
}
$HIPLDFLAGS .= " -lsupc++";
$HIPLDFLAGS .= " -L$HSA_PATH/lib -L$ROCM_PATH/lib -lhsa-runtime64 -lhc_am -lhsakmt";
# Add trace marker library:
@@ -148,8 +139,6 @@ if ($HIP_PLATFORM eq "hcc") {
$HIPLDFLAGS .= " -L$marker_lib_path -lCXLActivityLogger -Wl,--rpath=$marker_lib_path";
}
# Add C++ libs for GCC.
$HIPLDFLAGS .= " -lstdc++";
$HIPLDFLAGS .= " -lm";
if ($verbose & 0x2) {
@@ -271,7 +260,6 @@ foreach $arg (@ARGV)
}
if(($trimarg eq '-stdlib=libstdc++') and ($setStdLib eq 0))
{
$HIPCXXFLAGS .= " -stdlib=libstdc++";
$HIPCXXFLAGS .= $HCC_WA_FLAGS;
$setStdLib = 1;
}
@@ -372,7 +360,6 @@ if ($buildDeps and $HIP_PLATFORM eq 'nvcc') {
if ($setStdLib eq 0 and $HIP_PLATFORM eq 'hcc')
{
$HIPCXXFLAGS .= " -stdlib=libstdc++";
$HIPCXXFLAGS .= $HCC_WA_FLAGS;
}
+1 -1
View File
@@ -21,7 +21,7 @@ THE SOFTWARE.
*/
/* HIT_START
* BUILD: %t %s ../test_common.cpp HCC_OPTIONS -stdlib=libc++
* BUILD: %t %s ../test_common.cpp
* RUN: %t
* HIT_END
*/
+2 -2
View File
@@ -22,8 +22,8 @@ THE SOFTWARE.
// Test the HCC-specific API extensions for HIP:
/* HIT_START
* BUILD: %t %s HCC_OPTIONS -stdlib=libc++
* RUN: %t
* BUILD: %t %s
* RUN: %t EXCLUDE_HIP_PLATFORM all
* HIT_END
*/
+1 -1
View File
@@ -22,7 +22,7 @@ THE SOFTWARE.
// Collection of code to make sure that various features in the hip kernel language compile.
/* HIT_START
* BUILD: %t %s ../test_common.cpp HCC_OPTIONS -stdlib=libc++
* BUILD: %t %s ../test_common.cpp
* RUN: %t
* HIT_END
*/