From d4a364b8c620ece6e857fb6c95f6633f013a70d3 Mon Sep 17 00:00:00 2001 From: Tao Sang Date: Fri, 17 Apr 2020 10:13:08 -0500 Subject: [PATCH] Revert "Solve issues with hip-vdi runtime static lib" This reverts commit 8a42ac4d03c7a88f7c16da51dce15dee080f0ca3. Reason for revert: It is causing dkms-no-npi-hipclang broken. It is top priority to maintain dkms-no-npi-hipclang build, otherwise we lose track of regression analysis. So revert the change for now and recommit it after fixing it. Change-Id: Ia5136e888baecb6148c6c18eedbf37066fcb1eaa [ROCm/hip commit: f246761deebdf92254852e48580804f1868e0d29] --- projects/hip/bin/hipcc | 14 ++++------- .../hip/samples/0_Intro/bit_extract/Makefile | 7 +----- projects/hip/samples/0_Intro/square/Makefile | 7 ++---- projects/hip/vdi/CMakeLists.txt | 23 ++++--------------- projects/hip/vdi/hip_internal.hpp | 6 ----- projects/hip/vdi/hip_platform.cpp | 2 +- 6 files changed, 13 insertions(+), 46 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 25b9078cd6..5ed781bc60 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -211,7 +211,10 @@ if ($HIP_PLATFORM eq "clang") { $HIPCXXFLAGS .= " -isystem $HIP_CLANG_INCLUDE_PATH/.."; $HIPCFLAGS .= " -isystem $HIP_CLANG_INCLUDE_PATH/.."; $HIPLDFLAGS .= " -L$HIP_LIB_PATH"; - if ($isWindows) { + if (not $isWindows) { + $HIPLDFLAGS .= " -Wl,--rpath-link=$HIP_LIB_PATH"; + $HIPLDFLAGS .= " -lhip_hcc"; + } else { $HIPLDFLAGS .= " -lamdhip64"; } if ($HIP_CLANG_HCC_COMPAT_MODE) { @@ -477,7 +480,6 @@ foreach $arg (@ARGV) { $linkType = 0; $setLinkType = 1; - $swallowArg = 1; } if(($trimarg eq '-use-sharedlib') and ($setLinkType eq 0)) { @@ -768,14 +770,6 @@ if ($HIP_PLATFORM eq "clang") { if (not $isWindows) { $HIPLDFLAGS .= " -lgcc_s -lgcc -lpthread -lm"; } - - if (not $isWindows and not $compileOnly) { - if ($linkType eq 0) { - $toolArgs .= " -L$HIP_LIB_PATH -lamdhip64_static -L$ROCM_PATH/lib -lhsa-runtime64 -ldl "; - } else { - $toolArgs .= " -Wl,--enable-new-dtags -Wl,--rpath=$HIP_LIB_PATH:$ROCM_PATH/lib -lhip_hcc "; - } - } } diff --git a/projects/hip/samples/0_Intro/bit_extract/Makefile b/projects/hip/samples/0_Intro/bit_extract/Makefile index 4a3a0bb4fe..08bca6e642 100644 --- a/projects/hip/samples/0_Intro/bit_extract/Makefile +++ b/projects/hip/samples/0_Intro/bit_extract/Makefile @@ -13,15 +13,10 @@ ifeq (${HIP_PLATFORM}, nvcc) endif EXE=bit_extract -EXE_STATIC=bit_extract_static $(EXE): bit_extract.cpp $(HIPCC) $(HIPCC_FLAGS) $< -o $@ -$(EXE_STATIC): bit_extract.cpp - $(HIPCC) -use-staticlib $(HIPCC_FLAGS) $< -o $@ - -all: $(EXE) $(EXE_STATIC) clean: - rm -f *.o $(EXE) $(EXE_STATIC) + rm -f *.o $(EXE) diff --git a/projects/hip/samples/0_Intro/square/Makefile b/projects/hip/samples/0_Intro/square/Makefile index aa046eeaaa..9bb0dd8205 100644 --- a/projects/hip/samples/0_Intro/square/Makefile +++ b/projects/hip/samples/0_Intro/square/Makefile @@ -11,7 +11,7 @@ else SOURCES=square.cpp endif -all: square.out square.out.static +all: square.out # Step square.cpp: square.cu @@ -20,8 +20,5 @@ square.cpp: square.cu square.out: $(SOURCES) $(HIPCC) $(CXXFLAGS) $(SOURCES) -o $@ -square.out.static: $(SOURCES) - $(HIPCC) -use-staticlib $(CXXFLAGS) $(SOURCES) -o $@ - clean: - rm -f *.o *.out *.out.static square.cpp + rm -f *.o *.out square.cpp diff --git a/projects/hip/vdi/CMakeLists.txt b/projects/hip/vdi/CMakeLists.txt index aa82dec373..8c1ca1f2de 100644 --- a/projects/hip/vdi/CMakeLists.txt +++ b/projects/hip/vdi/CMakeLists.txt @@ -152,33 +152,21 @@ add_library(amdhip64 SHARED $ ) -add_library(amdhip64_static_base STATIC +add_library(amdhip64_static STATIC $ ) add_library(host INTERFACE) target_link_libraries(host INTERFACE amdhip64) -target_link_libraries(host INTERFACE amdhip64_static_base) add_library(device INTERFACE) target_link_libraries(device INTERFACE host) -target_link_libraries(amdhip64_static_base PRIVATE amdvdi_static pthread dl) +target_link_libraries(amdhip64_static PRIVATE amdvdi_static pthread dl) target_link_libraries(amdhip64 PRIVATE amdvdi_static pthread dl) -set(STATICLIBNAME "${hip_BINARY_DIR}/lib/libamdhip64_static.a") - -add_custom_command( - OUTPUT ${STATICLIBNAME} - COMMAND rm -f ${STATICLIBNAME} - COMMAND ${CMAKE_AR} -rcsT ${STATICLIBNAME} $ $ - DEPENDS amdhip64_static_base amdvdi_static - COMMENT "Combining static libs into ${STATICLIBNAME} " -) - -add_custom_target(amdhip64_static ALL - DEPENDS ${STATICLIBNAME} -) +INSTALL(PROGRAMS $ DESTINATION lib COMPONENT MAIN) +INSTALL(PROGRAMS $ DESTINATION lib COMPONENT MAIN) INSTALL(CODE "execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink libamdhip64.so lib/libhip_hcc.so )" DESTINATION lib COMPONENT MAIN) INSTALL(CODE "execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink libamdhip64.so lib/libhiprtc.so )" DESTINATION lib COMPONENT MAIN) @@ -186,7 +174,6 @@ INSTALL(FILES ${CMAKE_BINARY_DIR}/lib/libhip_hcc.so DESTINATION lib COMPONENT MA INSTALL(FILES ${CMAKE_BINARY_DIR}/lib/libhiprtc.so DESTINATION lib COMPONENT MAIN) -INSTALL(PROGRAMS ${STATICLIBNAME} DESTINATION ${LIB_INSTALL_DIR}) -INSTALL(TARGETS amdhip64_static_base amdhip64 host device EXPORT hip-targets DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(TARGETS amdhip64_static amdhip64 host device EXPORT hip-targets DESTINATION ${LIB_INSTALL_DIR}) INSTALL(EXPORT hip-targets DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR} NAMESPACE hip::) diff --git a/projects/hip/vdi/hip_internal.hpp b/projects/hip/vdi/hip_internal.hpp index 10819350f5..9b4bd17042 100755 --- a/projects/hip/vdi/hip_internal.hpp +++ b/projects/hip/vdi/hip_internal.hpp @@ -132,7 +132,6 @@ namespace hip { extern void init(); extern Device* getCurrentDevice(); - extern void setCurrentDevice(unsigned int index); /// Get VDI queue associated with hipStream @@ -256,11 +255,6 @@ private: ~PlatformState() {} public: static PlatformState& instance() { - if (platform_ == nullptr) { - // __hipRegisterFatBinary() will call this when app starts, thus - // there is no multiple entry issue here. - platform_ = new PlatformState(); - } return *platform_; } diff --git a/projects/hip/vdi/hip_platform.cpp b/projects/hip/vdi/hip_platform.cpp index 52ad36c29d..5ece473e06 100755 --- a/projects/hip/vdi/hip_platform.cpp +++ b/projects/hip/vdi/hip_platform.cpp @@ -30,7 +30,7 @@ constexpr unsigned __hipFatMAGIC2 = 0x48495046; // "HIPF" thread_local std::stack execStack_; -PlatformState* PlatformState::platform_ = nullptr; +PlatformState* PlatformState::platform_ = new PlatformState(); struct __CudaFatBinaryWrapper { unsigned int magic;