C++ filesystem and link to dl library in test exe (#29)
* Add lib/rocprofiler-register/details/filesystem.hpp - this provides backwards compatibility for compiler which do not have <filesystem> - use <experimental/filesystem> when not available * Update tests/CMakeLists.txt - test executables link to dl library (via CMAKE_DL_LIBS) * Update CI workflow - include ubuntu-20.04 jobs
This commit is contained in:
@@ -32,6 +32,14 @@ jobs:
|
||||
compiler: 'clang-15'
|
||||
ci-args: '--linter clang-tidy'
|
||||
ci-tag: '-clang-tidy'
|
||||
- runner: 'ubuntu-20.04'
|
||||
compiler: 'gcc-9'
|
||||
ci-args: ''
|
||||
ci-tag: ''
|
||||
- runner: 'ubuntu-20.04'
|
||||
compiler: 'clang-10'
|
||||
ci-args: ''
|
||||
ci-tag: ''
|
||||
# - runner: 'ubuntu-latest'
|
||||
# compiler: 'gcc-12'
|
||||
# ci-args: '--memcheck ThreadSanitizer'
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
#
|
||||
set(rocprofiler_register_details_sources dl.cpp utility.cpp)
|
||||
|
||||
set(rocprofiler_register_details_headers environment.hpp dl.hpp utility.hpp)
|
||||
set(rocprofiler_register_details_headers environment.hpp dl.hpp filesystem.hpp
|
||||
utility.hpp)
|
||||
|
||||
target_sources(rocprofiler-register PRIVATE ${rocprofiler_register_details_sources}
|
||||
${rocprofiler_register_details_headers})
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
#define GNU_SOURCE 1
|
||||
|
||||
#include "dl.hpp"
|
||||
#include "filesystem.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@@ -38,8 +38,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace fs = ::std::filesystem;
|
||||
|
||||
namespace rocprofiler_register
|
||||
{
|
||||
namespace binary
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined __has_include
|
||||
# if __has_include(<version>)
|
||||
# include <version>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__cpp_lib_filesystem)
|
||||
# define ROCPROFILER_REGISTER_HAS_CPP_LIB_FILESYSTEM 1
|
||||
#else
|
||||
# if defined __has_include
|
||||
# if __has_include(<filesystem>)
|
||||
# include <filesystem>
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(ROCPROFILER_REGISTER_HAS_CPP_LIB_FILESYSTEM) && \
|
||||
ROCPROFILER_REGISTER_HAS_CPP_LIB_FILESYSTEM > 0
|
||||
# include <filesystem>
|
||||
namespace fs = ::std::filesystem; // NOLINT
|
||||
#else
|
||||
# include <experimental/filesystem>
|
||||
namespace fs = ::std::experimental::filesystem; // NOLINT
|
||||
#endif
|
||||
@@ -24,12 +24,12 @@
|
||||
|
||||
#include "details/dl.hpp"
|
||||
#include "details/environment.hpp"
|
||||
#include "details/filesystem.hpp"
|
||||
#include "glog/logging.h"
|
||||
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <bitset>
|
||||
#include <filesystem>
|
||||
#include <mutex>
|
||||
#include <regex>
|
||||
#include <stdexcept>
|
||||
@@ -75,7 +75,6 @@ rocprofiler_register_import_roctx_static(void);
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace fs = ::std::filesystem;
|
||||
using namespace rocprofiler_register;
|
||||
using rocprofiler_set_api_table_t = decltype(::rocprofiler_set_api_table)*;
|
||||
using bitset_t = std::bitset<sizeof(rocprofiler_register_library_indentifier_t::handle)>;
|
||||
|
||||
+10
-1
@@ -56,6 +56,14 @@ function(rocp_register_strip_target)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(NOT CMAKE_DL_LIBS)
|
||||
find_library(DL_LIBRARY NAMES dl)
|
||||
if(NOT DL_LIBRARY)
|
||||
set(DL_LIBRARY dl)
|
||||
endif()
|
||||
set(CMAKE_DL_LIBS ${DL_LIBRARY})
|
||||
endif()
|
||||
|
||||
#
|
||||
# mock libraries
|
||||
#
|
||||
@@ -72,7 +80,8 @@ find_package(Threads REQUIRED)
|
||||
add_library(rocprofiler-register-tests-common INTERFACE)
|
||||
target_include_directories(rocprofiler-register-tests-common
|
||||
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>)
|
||||
target_link_libraries(rocprofiler-register-tests-common INTERFACE Threads::Threads stdc++)
|
||||
target_link_libraries(rocprofiler-register-tests-common INTERFACE Threads::Threads stdc++
|
||||
${CMAKE_DL_LIBS})
|
||||
|
||||
add_library(rocprofiler-register-tests-strong INTERFACE)
|
||||
target_compile_definitions(rocprofiler-register-tests-strong
|
||||
|
||||
Reference in New Issue
Block a user