From 1cb198dba2120f698397ff79bd862aa635d2f873 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 24 Apr 2020 13:58:31 -0400 Subject: [PATCH] Avoid intermediate object library Object libraries are weird, and producing a library by using the target objects from them doesn't automatically import the interface properties of the linked targets. These object libraries only have single uses, so just directly create the final library from the sources. Leaves libelf as an object library, since there seems to be some cmake oddity when trying to link an unexported target to an exported one. Change-Id: Ic379612c89340c40085c9862cfe111fa4bbff425 [ROCm/clr commit: cba7a4d20ebf015eb8005f929bdf02a508696c25] --- projects/clr/rocclr/CMakeLists.txt | 41 ++++++++++--------- .../rocclr/elf/utils/libelf/CMakeLists.txt | 8 +--- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/projects/clr/rocclr/CMakeLists.txt b/projects/clr/rocclr/CMakeLists.txt index 16788cf23d..384f95e31a 100644 --- a/projects/clr/rocclr/CMakeLists.txt +++ b/projects/clr/rocclr/CMakeLists.txt @@ -4,6 +4,8 @@ cmake_minimum_required(VERSION 3.5) #cmake -DOPENCL_DIR=/path to/opencl .. +set(ROCCLR_EXPORTS_FILE "${CMAKE_CURRENT_BINARY_DIR}/amdvdi_staticTargets.cmake") + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") # FIXME: Should be option and ON/OFF, not yes/no variable. @@ -99,8 +101,9 @@ endif() set(COMGR_CPP device/comgrctx.cpp) -add_subdirectory( elf/utils/libelf "${CMAKE_CURRENT_BINARY_DIR}/libelf" ) -add_library(oclruntime OBJECT +add_subdirectory(elf/utils/libelf "${CMAKE_CURRENT_BINARY_DIR}/libelf" ) + +set(oclruntime_src thread/thread.cpp thread/monitor.cpp thread/semaphore.cpp @@ -132,31 +135,29 @@ add_library(oclruntime OBJECT elf/elf.cpp elf/elf_utils.cpp #${CMAKE_CURRENT_SOURCE_DIR}/compiler/tools/caching/cache.cpp - ${COMGR_CPP} ) -target_include_directories(oclruntime PUBLIC - $ - PRIVATE ${ROCR_INCLUDES} ${ROCT_INCLUDES}) - -target_compile_definitions(oclruntime PRIVATE BSD_LIBELF) - -set_target_properties(oclruntime PROPERTIES POSITION_INDEPENDENT_CODE ON) - add_library(amdvdi_static STATIC - $ - $ - ) + ${oclruntime_src} ${COMGR_CPP} + $) set_target_properties(amdvdi_static PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(amdvdi_static + PUBLIC + $ + PRIVATE + $ + ${ROCR_INCLUDES} + ${ROCT_INCLUDES}) + +target_compile_definitions(amdvdi_static PRIVATE BSD_LIBELF) if(${USE_COMGR_LIBRARY} MATCHES "yes") # FIXME: This should not be part of the public interface. Downstream # users need to add these definitions. This should be defined in a # config header here so other builds don't need to be aware of this. - target_compile_definitions(oclruntime PUBLIC USE_COMGR_LIBRARY COMGR_DYN_DLL) - target_compile_definitions(amdvdi_static INTERFACE USE_COMGR_LIBRARY COMGR_DYN_DLL) + target_compile_definitions(amdvdi_static PUBLIC USE_COMGR_LIBRARY COMGR_DYN_DLL) endif() target_link_libraries(amdvdi_static PUBLIC Threads::Threads) @@ -167,17 +168,17 @@ if (BUILD_PAL) target_link_libraries(amdvdi_static PRIVATE amdhsaloader) target_link_libraries(amdvdi_static PRIVATE pal) - target_compile_definitions(oclruntime PRIVATE WITH_PAL_DEVICE) + target_compile_definitions(amdvdi_static PRIVATE WITH_PAL_DEVICE) export(TARGETS amdvdi_static vdipal amdhsaloader amdhsacode pal addrlib vam metrohash cwpack gpuopen ddCore mpack rapidjson - FILE "${CMAKE_CURRENT_BINARY_DIR}/amdvdi_staticTargets.cmake" + FILE ${ROCCLR_EXPORTS_FILE} ) else() - target_compile_definitions(oclruntime PRIVATE WITH_HSA_DEVICE) + target_compile_definitions(amdvdi_static PRIVATE WITH_HSA_DEVICE) target_sources(amdvdi_static PRIVATE $) export(TARGETS amdvdi_static - FILE "${CMAKE_CURRENT_BINARY_DIR}/amdvdi_staticTargets.cmake" + FILE ${ROCCLR_EXPORTS_FILE} ) endif() diff --git a/projects/clr/rocclr/elf/utils/libelf/CMakeLists.txt b/projects/clr/rocclr/elf/utils/libelf/CMakeLists.txt index 69d9bd8d88..58e5f24bb4 100644 --- a/projects/clr/rocclr/elf/utils/libelf/CMakeLists.txt +++ b/projects/clr/rocclr/elf/utils/libelf/CMakeLists.txt @@ -6,9 +6,7 @@ file(GLOB sources ) add_library(oclelf_obj OBJECT ${sources}) -add_library(oclelf STATIC $) set_target_properties(oclelf_obj PROPERTIES POSITION_INDEPENDENT_CODE ON) -set_target_properties(oclelf PROPERTIES POSITION_INDEPENDENT_CODE ON) target_include_directories(oclelf_obj PRIVATE @@ -18,8 +16,4 @@ target_include_directories(oclelf_obj target_compile_definitions(oclelf_obj PUBLIC - BSD_LIBELF USE_MEMFILE) - -target_compile_definitions(oclelf - PUBLIC - BSD_LIBELF USE_MEMFILE) \ No newline at end of file + BSD_LIBELF USE_MEMFILE)