From 20eb17e0c2f00fefa4806062c6762ab4cee2a123 Mon Sep 17 00:00:00 2001 From: "Patrick Nelson (VS)" Date: Wed, 19 Aug 2026 10:28:00 -0700 Subject: [PATCH 1/2] Fix 599 (Ubuntu 26.04 compat) by statically linking libxml2.so --- THIRD-PARTY-NOTICES.txt | 23 ++++++++ src/CMakeLists.txt | 53 ++++++++++++++++++- src/Common.Lib/CMakeLists.txt | 8 ++- src/InstrumentationEngine.Lib/CMakeLists.txt | 10 ++-- .../InstrumentationEngine.nuspec | 1 + src/InstrumentationEngine/CMakeLists.txt | 5 +- src/Tests/CommonLibTests/CMakeLists.txt | 4 +- .../CMakeLists.txt | 4 +- .../CMakeLists.txt | 4 +- src/build.sh | 12 ++--- .../components/libxml2/cgmanifest.json | 17 ++++++ 11 files changed, 114 insertions(+), 27 deletions(-) create mode 100644 THIRD-PARTY-NOTICES.txt create mode 100644 src/unix/docker/context/components/libxml2/cgmanifest.json diff --git a/THIRD-PARTY-NOTICES.txt b/THIRD-PARTY-NOTICES.txt new file mode 100644 index 00000000..99937cc1 --- /dev/null +++ b/THIRD-PARTY-NOTICES.txt @@ -0,0 +1,23 @@ +libxml2 +======= + +Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved. +Copyright (C) The Libxml2 Contributors. + +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. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8b2baf39..4741492a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -# Require at least version 3.14 of CMake -cmake_minimum_required(VERSION 3.14) +# Require at least version 3.18 of CMake +cmake_minimum_required(VERSION 3.18) IF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}" OR NOT IS_DIRECTORY "${CMAKE_INSTALL_PREFIX}") message(FATAL_ERROR "Required property CMAKE_INSTALL_PREFIX not correctly defined.") @@ -233,6 +233,53 @@ function(generate_exports_file inputFilename versionName outputFilename) PROPERTIES GENERATED TRUE) endfunction() +function(fetch_libxml2) + include(FetchContent) + + set(BUILD_SHARED_LIBS OFF) + set(LIBXML2_WITH_C14N OFF) + set(LIBXML2_WITH_CATALOG OFF) + set(LIBXML2_WITH_DEBUG OFF) + set(LIBXML2_WITH_DOCS OFF) + set(LIBXML2_WITH_HTML OFF) + set(LIBXML2_WITH_HTTP OFF) + set(LIBXML2_WITH_ICU OFF) + set(LIBXML2_WITH_MODULES OFF) + set(LIBXML2_WITH_OUTPUT OFF) + set(LIBXML2_WITH_PATTERN OFF) + set(LIBXML2_WITH_PROGRAMS OFF) + set(LIBXML2_WITH_PYTHON OFF) + set(LIBXML2_WITH_READER OFF) + set(LIBXML2_WITH_REGEXPS OFF) + set(LIBXML2_WITH_RELAXNG OFF) + set(LIBXML2_WITH_SCHEMAS OFF) + set(LIBXML2_WITH_SCHEMATRON OFF) + set(LIBXML2_WITH_TESTS OFF) + set(LIBXML2_WITH_WRITER OFF) + set(LIBXML2_WITH_XINCLUDE OFF) + set(LIBXML2_WITH_XPATH OFF) + set(LIBXML2_WITH_XPTR OFF) + set(LIBXML2_WITH_ZLIB OFF) + + FetchContent_Declare( + libxml2 + URL https://download.gnome.org/sources/libxml2/2.15/libxml2-2.15.3.tar.xz + URL_HASH SHA256=78262a6e7ac170d6528ebfe2efccdf220191a5af6a6cd61ea4a9a9a5042c7a07 + ) + FetchContent_MakeAvailable(libxml2) + + set_target_properties(LibXml2 PROPERTIES + C_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN true + ) + + if(CMAKE_SYSTEM_NAME STREQUAL Linux) + target_link_options(LibXml2 INTERFACE + "LINKER:--exclude-libs,libxml2.a" + ) + endif() +endfunction() + macro (fetch_google_test) include(FetchContent) FetchContent_Declare( @@ -365,6 +412,8 @@ add_library_pal(coreclrpal true ${CORECLR_PAL_ROOT}/lib/${CMAKE_BUILD_TYPE}/libc add_library_pal(palrt true ${CORECLR_PAL_ROOT}/lib/${CMAKE_BUILD_TYPE}/libpalrt.a) add_library_pal(corguids false ${CORECLR_PAL_ROOT}/lib/${CMAKE_BUILD_TYPE}/libcorguids.a) +fetch_libxml2() + add_subdirectory(unix/src) add_subdirectory(unix/src/atl) add_subdirectory(Common.Lib) diff --git a/src/Common.Lib/CMakeLists.txt b/src/Common.Lib/CMakeLists.txt index 0ded00b4..81cbef2c 100644 --- a/src/Common.Lib/CMakeLists.txt +++ b/src/Common.Lib/CMakeLists.txt @@ -3,9 +3,8 @@ cmake_minimum_required(VERSION 3.14) project(Common.Lib) -find_package(LibXml2 REQUIRED) -include_directories(. ${LIBXML2_INCLUDE_DIR}) +include_directories(.) build_init(CPP Common.Lib) #note: we purposfully exclude windows-only files, @@ -28,4 +27,9 @@ add_lib(${PROJECT_NAME} ${src_files} ) +target_link_libraries(${PROJECT_NAME} + PUBLIC + LibXml2::LibXml2 +) + #target_compile_options(Common.Lib PUBLIC "-H") \ No newline at end of file diff --git a/src/InstrumentationEngine.Lib/CMakeLists.txt b/src/InstrumentationEngine.Lib/CMakeLists.txt index ad1843e1..6b48c406 100644 --- a/src/InstrumentationEngine.Lib/CMakeLists.txt +++ b/src/InstrumentationEngine.Lib/CMakeLists.txt @@ -3,9 +3,8 @@ cmake_minimum_required(VERSION 3.14) project(InstrumentationEngine.Lib) -find_package(LibXml2 REQUIRED) -include_directories(. ${LIBXML2_INCLUDE_DIR}) +include_directories(.) build_init(CPP InstrumentationEngine.Lib) @@ -30,4 +29,9 @@ add_lib(${PROJECT_NAME} true # use_redefines false # hide_symbols ${src_files} - ) \ No newline at end of file + ) + +target_link_libraries(${PROJECT_NAME} + PRIVATE + LibXml2::LibXml2 +) \ No newline at end of file diff --git a/src/InstrumentationEngine.NuGet/InstrumentationEngine.nuspec b/src/InstrumentationEngine.NuGet/InstrumentationEngine.nuspec index b93b5be8..16e906e4 100644 --- a/src/InstrumentationEngine.NuGet/InstrumentationEngine.nuspec +++ b/src/InstrumentationEngine.NuGet/InstrumentationEngine.nuspec @@ -26,6 +26,7 @@ + diff --git a/src/InstrumentationEngine/CMakeLists.txt b/src/InstrumentationEngine/CMakeLists.txt index 7d4eeed9..6ab5a242 100644 --- a/src/InstrumentationEngine/CMakeLists.txt +++ b/src/InstrumentationEngine/CMakeLists.txt @@ -5,9 +5,7 @@ cmake_minimum_required(VERSION 2.8.12) project(InstrumentationEngine) -find_package(LibXml2 REQUIRED) - -include_directories(. ../InstrumentationEngine.Lib ${LIBXML2_INCLUDE_DIR}) +include_directories(. ../InstrumentationEngine.Lib) build_init(CPP InstrumentationEngine) @@ -90,7 +88,6 @@ endif() target_link_libraries(${PROJECT_NAME} pthread stdc++ - ${LIBXML2_LIBRARIES} ${CORECLRPAL} ${LINUXPAL} ${ATL} diff --git a/src/Tests/CommonLibTests/CMakeLists.txt b/src/Tests/CommonLibTests/CMakeLists.txt index 1e272b92..96287d3e 100644 --- a/src/Tests/CommonLibTests/CMakeLists.txt +++ b/src/Tests/CommonLibTests/CMakeLists.txt @@ -7,10 +7,9 @@ cmake_minimum_required(VERSION 3.14) fetch_google_test() project(Common.LibTests) -find_package(LibXml2 REQUIRED) # the midl directory is needed to replace the rpc headers referenced by midl generated headers. -include_directories(. ${REPOSITORY_ROOT}/src/unix/inc/midl ${REPOSITORY_ROOT}/src ${LIBXML2_INCLUDE_DIR}) +include_directories(. ${REPOSITORY_ROOT}/src/unix/inc/midl ${REPOSITORY_ROOT}/src) build_init(CPP Common.LibTests) @@ -29,7 +28,6 @@ add_executable( target_link_libraries( ${PROJECT_NAME} - ${LIBXML2_LIBRARIES} Common.Lib gtest_main ) diff --git a/src/Tests/InstrEngineTests/NaglerInstrumentationMethod/CMakeLists.txt b/src/Tests/InstrEngineTests/NaglerInstrumentationMethod/CMakeLists.txt index fc94ca72..9d7b4609 100644 --- a/src/Tests/InstrEngineTests/NaglerInstrumentationMethod/CMakeLists.txt +++ b/src/Tests/InstrEngineTests/NaglerInstrumentationMethod/CMakeLists.txt @@ -4,9 +4,8 @@ cmake_minimum_required(VERSION 3.14) project(NaglerInstrumentationEngine) -find_package(LibXml2 REQUIRED) -include_directories(. ${REPOSITORY_ROOT}/src ${LIBXML2_INCLUDE_DIR}) +include_directories(. ${REPOSITORY_ROOT}/src) # don't use the PAL for tests build_init(CPP InstrumentationEngine) @@ -47,7 +46,6 @@ target_link_libraries( ${PROJECT_NAME} pthread stdc++ - ${LIBXML2_LIBRARIES} Common.Lib ) diff --git a/src/Tests/InstrumentationEngineLibTests/CMakeLists.txt b/src/Tests/InstrumentationEngineLibTests/CMakeLists.txt index c08989b6..a85cb400 100644 --- a/src/Tests/InstrumentationEngineLibTests/CMakeLists.txt +++ b/src/Tests/InstrumentationEngineLibTests/CMakeLists.txt @@ -7,9 +7,8 @@ cmake_minimum_required(VERSION 3.14) fetch_google_test() project(InstrumentationEngine.LibTests) -find_package(LibXml2 REQUIRED) -include_directories(. ${REPOSITORY_ROOT}/src ${LIBXML2_INCLUDE_DIR}) +include_directories(. ${REPOSITORY_ROOT}/src) # don't use the PAL for tests build_init(CPP InstrumentationEngine.LibTests) @@ -58,7 +57,6 @@ target_link_libraries( ${PROJECT_NAME} pthread stdc++ - ${LIBXML2_LIBRARIES} ${CORECLRPAL} ${LINUXPAL} ${ATL} diff --git a/src/build.sh b/src/build.sh index 6e695f67..e1e17ed7 100755 --- a/src/build.sh +++ b/src/build.sh @@ -134,15 +134,13 @@ get_cmake() echo "found cmake version $cmakeVersion" cmakeMajor=$(echo $cmakeVersion | sed 's/^.*[^0-9]\([0-9]*\)\..*$/\1'/) cmakeMinor=$(echo $cmakeVersion | sed 's/^.*[^0-9]*\.\([0-9]*\)\..*$/\1'/) - if (( $cmakeMajor > 3 )); then - if (( $cmakeMinor >= 14 )); then - # found sufficient cmake, continue. - echo $cmakeLocation - return - fi + if (( $cmakeMajor > 3 || ($cmakeMajor == 3 && $cmakeMinor >= 18) )); then + # found sufficient cmake, continue. + echo $cmakeLocation + return fi - echo "Insufficient cmake version. Ensure cmake version 3.14 or later is installed" + echo "Insufficient cmake version. Ensure cmake version 3.18 or later is installed" exit 1 } diff --git a/src/unix/docker/context/components/libxml2/cgmanifest.json b/src/unix/docker/context/components/libxml2/cgmanifest.json new file mode 100644 index 00000000..0937099c --- /dev/null +++ b/src/unix/docker/context/components/libxml2/cgmanifest.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://json.schemastore.org/component-detection-manifest.json", + "Registrations": [ + { + "Component": { + "Type": "other", + "other": { + "Name": "libxml2", + "Version": "2.15.3", + "DownloadUrl": "https://download.gnome.org/sources/libxml2/2.15/libxml2-2.15.3.tar.xz", + "SHA256CHECK": "78262a6e7ac170d6528ebfe2efccdf220191a5af6a6cd61ea4a9a9a5042c7a07" + } + }, + "DevelopmentDependency": false + } + ] +} From 8cbd19b647b098f69f37d9cbe8cc65c4ebe7c042 Mon Sep 17 00:00:00 2001 From: "Patrick Nelson (VS)" Date: Wed, 19 Aug 2026 11:26:32 -0700 Subject: [PATCH 2/2] PR Feedback --- THIRD-PARTY-NOTICES.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/THIRD-PARTY-NOTICES.txt b/THIRD-PARTY-NOTICES.txt index 99937cc1..ab372aa7 100644 --- a/THIRD-PARTY-NOTICES.txt +++ b/THIRD-PARTY-NOTICES.txt @@ -1,3 +1,20 @@ +NOTICES AND INFORMATION +Do Not Translate or Localize + +This software incorporates material from third parties. +Microsoft makes certain open source code available at https://3rdpartysource.microsoft.com, +or you may send a check or money order for US $5.00, including the product name, +the open source component name, platform, and version number, to: + +Source Code Compliance Team +Microsoft Corporation +One Microsoft Way +Redmond, WA 98052 +USA + +Notwithstanding any other terms, you may reverse engineer this software to the extent +required to debug changes to any libraries licensed under the GNU Lesser General Public License. + libxml2 =======