From 8f8855350715fbe02faa395f2162c3eba306d52a Mon Sep 17 00:00:00 2001 From: bcsgh <33939446+bcsgh@users.noreply.github.com> Date: Mon, 22 Jan 2024 13:27:33 -0800 Subject: [PATCH 1/2] [CI] Make cmake.c++20*.test actualy use C++20 and add cmake.c++23*.test (#2496) --- .github/workflows/ci.yml | 53 ++++++++++++++++++++++++++++++++++++++++ ci/do_ci.sh | 28 ++++++++++++++++++++- 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a0b0121f56..2e4fc46b58 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -358,6 +358,59 @@ jobs: CXX_STANDARD: '20' run: ./ci/do_ci.sh cmake.c++20.stl.test + cmake_test_cxx23_gcc: + name: CMake C++23 test(GCC) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - name: setup + env: + CMAKE_VERSION: 3.20.6 + run: | + sudo -E ./ci/setup_ci_environment.sh + sudo -E ./ci/setup_cmake.sh + - name: run tests + env: + CXX_STANDARD: '23' + run: ./ci/do_ci.sh cmake.c++23.test + - name: run tests (enable stl) + env: + CXX_STANDARD: '23' + run: ./ci/do_ci.sh cmake.c++23.stl.test + + cmake_test_cxx23_clang: + name: CMake C++23 test(Clang with libc++) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - name: setup + env: + CC: /usr/bin/clang + CXX: /usr/bin/clang++ + CXXFLAGS: "-stdlib=libc++" + CMAKE_VERSION: 3.20.6 + run: | + sudo -E ./ci/setup_ci_environment.sh + sudo -E ./ci/setup_cmake.sh + - name: run tests + env: + CC: /usr/bin/clang + CXX: /usr/bin/clang++ + CXXFLAGS: "-stdlib=libc++" + CXX_STANDARD: '23' + run: ./ci/do_ci.sh cmake.c++23.test + - name: run tests (enable stl) + env: + CC: /usr/bin/clang + CXX: /usr/bin/clang++ + CXXFLAGS: "-stdlib=libc++" + CXX_STANDARD: '23' + run: ./ci/do_ci.sh cmake.c++23.stl.test + cmake_otprotocol_test: name: CMake test (with otlp-exporter) runs-on: ubuntu-20.04 diff --git a/ci/do_ci.sh b/ci/do_ci.sh index fa8249563c..4a3b616c8a 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -229,6 +229,19 @@ elif [[ "$1" == "cmake.c++20.test" ]]; then cmake ${CMAKE_OPTIONS[@]} \ -DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS" \ -DWITH_ASYNC_EXPORT_PREVIEW=ON \ + -DWITH_STL=CXX20 \ + ${IWYU} \ + "${SRC_DIR}" + eval "$MAKE_COMMAND" + make test + exit 0 +elif [[ "$1" == "cmake.c++23.test" ]]; then + cd "${BUILD_DIR}" + rm -rf * + cmake ${CMAKE_OPTIONS[@]} \ + -DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS" \ + -DWITH_ASYNC_EXPORT_PREVIEW=ON \ + -DWITH_STL=CXX23 \ ${IWYU} \ "${SRC_DIR}" eval "$MAKE_COMMAND" @@ -267,7 +280,20 @@ elif [[ "$1" == "cmake.c++20.stl.test" ]]; then -DWITH_METRICS_EXEMPLAR_PREVIEW=ON \ -DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS" \ -DWITH_ASYNC_EXPORT_PREVIEW=ON \ - -DWITH_STL=ON \ + -DWITH_STL=CXX20 \ + ${IWYU} \ + "${SRC_DIR}" + eval "$MAKE_COMMAND" + make test + exit 0 +elif [[ "$1" == "cmake.c++23.stl.test" ]]; then + cd "${BUILD_DIR}" + rm -rf * + cmake ${CMAKE_OPTIONS[@]} \ + -DWITH_METRICS_EXEMPLAR_PREVIEW=ON \ + -DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS" \ + -DWITH_ASYNC_EXPORT_PREVIEW=ON \ + -DWITH_STL=CXX23 \ ${IWYU} \ "${SRC_DIR}" eval "$MAKE_COMMAND" From a2323281adf60de8351c64861f313137bbbcebfd Mon Sep 17 00:00:00 2001 From: Mats Taraldsvik Date: Mon, 22 Jan 2024 23:27:48 +0100 Subject: [PATCH 2/2] [BUILD] Alternative way of exporting symbols (generating .def file) (#2476) --- ext/src/dll/CMakeLists.txt | 49 +++++++++++++++++++++++++--- ext/src/dll/input.src | 67 ++++++++++++++++++++++++++++++++++++++ ext/src/dll/make_def.ps1 | 8 +++++ 3 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 ext/src/dll/input.src create mode 100644 ext/src/dll/make_def.ps1 diff --git a/ext/src/dll/CMakeLists.txt b/ext/src/dll/CMakeLists.txt index 687d55e01f..e6772b839f 100644 --- a/ext/src/dll/CMakeLists.txt +++ b/ext/src/dll/CMakeLists.txt @@ -50,14 +50,55 @@ if(WITH_OTLP_HTTP) PRIVATE opentelemetry_exporter_otlp_http_log) endif() +find_program( + _vswhere_tool + NAMES vswhere + PATHS "$ENV{ProgramFiles\(x86\)}/Microsoft Visual Studio/Installer") +if(NOT ${vswhere}) + message( + FATAL_ERROR "Could not locate vswhere.exe - unable to locate dumpbin.exe") +endif() + +execute_process( + COMMAND "${_vswhere_tool}" -latest -find **/dumpbin.exe + OUTPUT_VARIABLE DUMPBIN_PATHS + RESULT_VARIABLE _vs_where_exitcode + OUTPUT_STRIP_TRAILING_WHITESPACE) + +message(STATUS "DUMPBIN PATHS: ${DUMPBIN_PATHS} ${RESULT_VARIABLE}") + +string(REPLACE "\n" ";" DUMPBIN_PATHS_LIST ${DUMPBIN_PATHS}) + +list(POP_FRONT DUMPBIN_PATHS_LIST DUMPBIN_PATH) + +message(STATUS "DUMPBIN PATH: ${DUMPBIN_PATH}") + +# find Powershell executable find_program(DUMPBIN_PATH NAMES dumpbin REQUIRED) + +# find Powershell executable +find_program(POWERSHELL_PATH NAMES pwsh powershell REQUIRED) + +set(OPENTELEMETRY_INPUT_DEF "${CMAKE_CURRENT_SOURCE_DIR}/input.txt") + add_custom_command( - OUTPUT ${OPENTELEMETRY_EXPORT_DEF} + OUTPUT ${OPENTELEMETRY_INPUT_DEF} + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/input.src" COMMAND ${CMAKE_CXX_COMPILER} "-D$,;-D>" /EP - ${CMAKE_CURRENT_SOURCE_DIR}/opentelemetry_cpp.src > - ${OPENTELEMETRY_EXPORT_DEF} - COMMAND_EXPAND_LISTS VERBATIM) + ${CMAKE_CURRENT_SOURCE_DIR}/input.src > ${OPENTELEMETRY_INPUT_DEF} + VERBATIM COMMAND_EXPAND_LISTS) + +add_custom_command( + OUTPUT ${OPENTELEMETRY_EXPORT_DEF} + DEPENDS "${OPENTELEMETRY_INPUT_DEF}" + "${CMAKE_CURRENT_SOURCE_DIR}/make_def.ps1" + COMMAND + ${POWERSHELL_PATH} "-ExecutionPolicy" "Bypass" "-File" + "${CMAKE_CURRENT_SOURCE_DIR}/make_def.ps1" "-dumpbin" "${DUMPBIN_PATH}" + "-bindir" ${PROJECT_BINARY_DIR} "-inputfile" ${OPENTELEMETRY_INPUT_DEF} + "-targetfile" ${OPENTELEMETRY_EXPORT_DEF} + VERBATIM) if(OPENTELEMETRY_INSTALL) install( diff --git a/ext/src/dll/input.src b/ext/src/dll/input.src new file mode 100644 index 0000000000..91ed42d303 --- /dev/null +++ b/ext/src/dll/input.src @@ -0,0 +1,67 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// clang-format off +Create@OStreamSpanExporterFactory@trace@exporter@v1@opentelemetry +Create@SimpleSpanProcessorFactory@trace@sdk@v1@opentelemetry +Create@TracerProviderFactory@trace@sdk@v1@opentelemetry +Create@LoggerProviderFactory@logs@sdk@v1@opentelemetry +Create@BatchLogRecordProcessorFactory@logs@sdk@v1@opentelemetry +Create@SimpleLogRecordProcessorFactory@logs@sdk@v1@opentelemetry +Create@MultiLogRecordProcessorFactory@logs@sdk@v1@opentelemetry +ForceFlush@TracerProvider@trace@sdk@v1@opentelemetry +ForceFlush@LoggerProvider@logs@sdk@v1@opentelemetry +OStreamLogRecordExporter@logs@exporter@v1@opentelemetry +Create@OStreamMetricExporterFactory@metrics@exporter@v1@opentelemetry +Create@PeriodicExportingMetricReaderFactory@metrics@sdk@v1@opentelemetry +Create@MeterProviderFactory@metrics@sdk@v1@opentelemetry +Create@MeterContextFactory@metrics@sdk@v1@opentelemetry +Create@ViewFactory@metrics@sdk@v1@opentelemetry +Create@MeterSelectorFactory@metrics@sdk@v1@opentelemetry +Create@InstrumentSelectorFactory@metrics@sdk@v1@opentelemetry +AddMetricReader@MeterContext@metrics@sdk@v1@opentelemetry +AddMetricReader@MeterProvider@metrics@sdk@v1@opentelemetry +AddView@MeterProvider@metrics@sdk@v1@opentelemetry + +#if defined(WITH_OTLP_GRPC) || defined(WITH_OTLP_HTTP) +GetOtlpDefaultTracesTimeout@otlp@exporter@v1@opentelemetry +GetOtlpDefaultTracesHeaders@otlp@exporter@v1@opentelemetry +GetOtlpDefaultLogsTimeout@otlp@exporter@v1@opentelemetry +GetOtlpDefaultLogsHeaders@otlp@exporter@v1@opentelemetry +GetOtlpDefaultMetricsTimeout@otlp@exporter@v1@opentelemetry +GetOtlpDefaultMetricsHeaders@otlp@exporter@v1@opentelemetry +GetOtlpDefaultTracesSslCertificatePath@otlp@exporter@v1@opentelemetry +GetOtlpDefaultMetricsSslCertificatePath@otlp@exporter@v1@opentelemetry +GetOtlpDefaultLogsSslCertificatePath@otlp@exporter@v1@opentelemetry +GetOtlpDefaultTracesSslCertificateString@otlp@exporter@v1@opentelemetry +GetOtlpDefaultMetricsSslCertificateString@otlp@exporter@v1@opentelemetry +GetOtlpDefaultLogsSslCertificateString@otlp@exporter@v1@opentelemetry +#endif // defined(WITH_OTLP_GRPC) || defined(WITH_OTLP_HTTP) + +#if defined(WITH_OTLP_GRPC) +Create@OtlpGrpcExporterFactory@otlp@exporter@v1@opentelemetry +Create@OtlpGrpcMetricExporterFactory@otlp@exporter@v1@opentelemetry +Create@OtlpGrpcLogRecordExporterFactory@otlp@exporter@v1@opentelemetry +OtlpGrpcExporterOptions@otlp@exporter@v1@opentelemetry +OtlpGrpcMetricExporterOptions@otlp@exporter@v1@opentelemetry +OtlpGrpcLogRecordExporterOptions@otlp@exporter@v1@opentelemetry +GetOtlpDefaultGrpcTracesEndpoint@otlp@exporter@v1@opentelemetry +GetOtlpDefaultGrpcMetricsEndpoint@otlp@exporter@v1@opentelemetry +GetOtlpDefaultGrpcLogsEndpoint@otlp@exporter@v1@opentelemetry +GetOtlpDefaultGrpcTracesIsInsecure@otlp@exporter@v1@opentelemetry +GetOtlpDefaultGrpcMetricsIsInsecure@otlp@exporter@v1@opentelemetry +GetOtlpDefaultGrpcLogsIsInsecure@otlp@exporter@v1@opentelemetry +#endif // defined(WITH_OTLP_GRPC) + +#if defined(WITH_OTLP_HTTP) +Create@OtlpHttpExporterFactory@otlp@exporter@v1@opentelemetry +Create@OtlpHttpMetricExporterFactory@otlp@exporter@v1@opentelemetry +Create@OtlpHttpLogRecordExporterFactory@otlp@exporter@v1@opentelemetry +OtlpHttpExporterOptions@otlp@exporter@v1@opentelemetry +OtlpHttpMetricExporterOptions@otlp@exporter@v1@opentelemetry +OtlpHttpLogRecordExporterOptions@otlp@exporter@v1@opentelemetry +GetOtlpDefaultHttpTracesEndpoint@otlp@exporter@v1@opentelemetry +GetOtlpDefaultHttpMetricsEndpoint@otlp@exporter@v1@opentelemetry +GetOtlpDefaultHttpLogsEndpoint@otlp@exporter@v1@opentelemetry +#endif // defined(WITH_OTLP_HTTP) +// clang-format on \ No newline at end of file diff --git a/ext/src/dll/make_def.ps1 b/ext/src/dll/make_def.ps1 new file mode 100644 index 0000000000..a7ee93bc47 --- /dev/null +++ b/ext/src/dll/make_def.ps1 @@ -0,0 +1,8 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +param ($dumpbin, $bindir, $inputfile, $targetfile) + + "LIBRARY opentelemetry_cpp`r`nEXPORTS`r`n" > $targetfile + + Get-ChildItem -Verbose -Path $bindir/sdk/*,$bindir/exporters/* -Include *.lib -Recurse | % { & "$dumpbin" /SYMBOLS $_ | Select-String -Pattern @(Get-Content -Verbose -Path "$inputfile" | Where-Object { $_.Trim() -ne '' } | % { "External\s+\|\s+(\?+[0-9]?$_[^\s]*)\s+\((.*)\)$" }) | % { "; $($_.matches.groups[2])`r`n$($_.matches.groups[1])" } >> $targetfile }