Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove vcpkg in favor of boostorg/math standalone #2151

Merged
Merged
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ __pycache__/
/build/
/out/
/tools/out/
/CMakeLists.txt.user
StephanTLavavej marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 3 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

[submodule "vcpkg"]
path = vcpkg
url = https://github.com/microsoft/vcpkg.git
fetchRecurseSubmodules = false
[submodule "llvm-project"]
path = llvm-project
url = https://github.com/llvm/llvm-project.git
[submodule "boost-math"]
path = boost-math
url = https://github.com/boostorg/math.git
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"files.exclude": {
"llvm-project": true,
"stl/msbuild": true,
"vcpkg": true
"boost-math": true
},
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
Expand Down
12 changes: 1 addition & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

if (NOT DEFINED CMAKE_TOOLCHAIN_FILE AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")
endif()

cmake_minimum_required(VERSION 3.20)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
project(msvc_standard_libraries LANGUAGES CXX)

find_package(Boost REQUIRED)

set(VCLIBS_MIN_BOOST_VERSION 1.76.0)
if("${Boost_VERSION}" VERSION_LESS "${VCLIBS_MIN_BOOST_VERSION}")
message(FATAL_ERROR "Detected Boost version is too old (older than ${VCLIBS_MIN_BOOST_VERSION}).")
endif()

option(BUILD_TESTING "Enable testing" ON)
set(VCLIBS_SUFFIX "_oss" CACHE STRING "suffix for built DLL names to avoid conflicts with distributed DLLs")

Expand Down Expand Up @@ -90,6 +79,7 @@ get_filename_component(TOOLSET_ROOT_DIR "${TOOLSET_ROOT_DIR}" DIRECTORY) # $\VC\

set(TOOLSET_LIB "${TOOLSET_ROOT_DIR}/lib/${VCLIBS_X86_OR_X64}")

add_subdirectory(boost-math)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change requested, just explaining for other reviewers. You mentioned:

The standalone mode requires the definition of the preprocessor macro BOOST_MATH_STANDALONE.

I found that this is automatically defined by boost-math's CMakeLists.txt:

cmake_dependent_option(BOOST_MATH_STANDALONE "Use Boost.Math in standalone mode" ON "NOT BOOST_SUPERPROJECT_VERSION" OFF)

message(STATUS "Boost.Math: standalone mode ${BOOST_MATH_STANDALONE}")

And running cmake for the STL repo prints:

-- Boost.Math: standalone mode ON

add_subdirectory(stl)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change requested - I noticed that special_math.cpp is defining the following macros:

#define BOOST_CHRONO_HEADER_ONLY
#define BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE

I suspect that we can drop them in standalone mode. However, that would force us to immediately convert the MSVC-internal build to also use standalone mode. While I think we should eventually do that, it looks like that will be more work than I initially thought, so it should be separate.

Specifically, I ran our internal Special Math tests (currently not in this repo for boring reasons; this is on our GitHub Migration backlog) and found that while they pass with the binaries shipping in VS 2022 17.0 Preview 3 (built with ancient Boost 1.66.0), there are 34 failures with Boost.Math standalone. The good news is that these are exactly the same failures as with microsoft/STL main using vcpkg, so that shouldn't block this PR. (Apparently Boost.Math did change behavior after 1.66.0 and we just hadn't noticed yet.)

I suspect that we need to regenerate the tests (in addition to updating them so they can run without a full copy of Boost) and that this doesn't indicate any physical problem with Boost.Math or our usage of it.

if(BUILD_TESTING)
Expand Down
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ Just try to follow these rules, so we can spend more time fixing bugs and implem

# How To Build With The Visual Studio IDE

The STL uses boost-math headers to provide P0226R1 Mathematical Special Functions. We recommend using [vcpkg][] to
acquire this dependency.

1. Install Visual Studio 2022 17.0 Preview 3 or later.
* We recommend selecting "C++ CMake tools for Windows" in the VS Installer.
This will ensure that you're using supported versions of CMake and Ninja.
Expand All @@ -152,10 +149,8 @@ acquire this dependency.
2. Open Visual Studio, and choose the "Clone or check out code" option. Enter the URL of this repository,
`https://github.com/microsoft/STL`.
3. Open a terminal in the IDE with `` Ctrl + ` `` (by default) or press on "View" in the top bar, and then "Terminal".
4. In the terminal, invoke `git submodule update --init --progress llvm-project vcpkg`
5. In the terminal, invoke `.\vcpkg\bootstrap-vcpkg.bat`
6. In the terminal, invoke `.\vcpkg\vcpkg.exe install boost-math:x86-windows boost-math:x64-windows`
7. Choose the architecture you wish to build in the IDE, and build as you would any other project. All necessary CMake
4. In the terminal, invoke `git submodule update --init --progress llvm-project boost-math`
5. Choose the architecture you wish to build in the IDE, and build as you would any other project. All necessary CMake
settings are set by `CMakeSettings.json`.

# How To Build With A Native Tools Command Prompt
Expand All @@ -170,9 +165,7 @@ acquire this dependency.
3. Change directories to a location where you'd like a clone of this STL repository.
4. `git clone https://github.com/microsoft/STL`
5. `cd STL`
6. `git submodule update --init --progress llvm-project vcpkg`
7. `.\vcpkg\bootstrap-vcpkg.bat`
8. `.\vcpkg\vcpkg.exe install boost-math:x86-windows boost-math:x64-windows`
6. `git submodule update --init --progress llvm-project boost-math`

To build the x86 target:

Expand Down Expand Up @@ -477,5 +470,4 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
[lit result codes]: https://llvm.org/docs/CommandGuide/lit.html#test-status-results
[opencode@microsoft.com]: mailto:opencode@microsoft.com
[redistributables]: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
[vcpkg]: https://github.com/microsoft/vcpkg
[natvis documentation]: https://docs.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects
26 changes: 13 additions & 13 deletions azure-devops/checkout-sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

parameters:
- name: vcpkgSHAVar
type: string
default: vcpkgSHA
- name: llvmSHAVar
type: string
default: llvmSHA
- name: boostMathSHAVar
type: string
default: boostMathSHA
steps:
- checkout: self
clean: true
Expand All @@ -22,8 +22,8 @@ steps:
$regexSubmoduleSHA = '^[ \-+]([0-9a-f]+) .*$'
$llvmSHA = git submodule status --cached llvm-project | %{$_ -replace $regexSubmoduleSHA, '$1'}
Write-Host "##vso[task.setvariable variable=${{ parameters.llvmSHAVar }};]$llvmSHA"
$vcpkgSHA = git submodule status --cached vcpkg | %{$_ -replace $regexSubmoduleSHA, '$1'}
Write-Host "##vso[task.setvariable variable=${{ parameters.vcpkgSHAVar }};]$vcpkgSHA"
$boostMathSHA = git submodule status --cached boost-math | %{$_ -replace $regexSubmoduleSHA, '$1'}
Write-Host "##vso[task.setvariable variable=${{ parameters.boostMathSHAVar }};]$boostMathSHA"
- script: |
cd $(Build.SourcesDirectory)
if not exist "llvm-project" (
Expand All @@ -50,22 +50,22 @@ steps:
displayName: "Checkout LLVM source"
- script: |
cd $(Build.SourcesDirectory)
if not exist "vcpkg" (
mkdir vcpkg
if not exist "boost-math" (
mkdir boost-math
)
cd vcpkg
cd boost-math

if not exist ".git" (
del /S /Q *
git init
)

git remote get-url vcpkg
git remote get-url boostorg
if errorlevel 1 (
git remote add vcpkg https://github.com/Microsoft/vcpkg.git
git config --local extensions.partialClone vcpkg
git remote add boostorg https://github.com/boostorg/math.git
git config --local extensions.partialClone boostorg
)

git fetch --filter=tree:0 --depth=1 vcpkg $(${{ parameters.vcpkgSHAVar }})
git fetch --filter=tree:0 --depth=1 boostorg $(${{ parameters.boostMathSHAVar }})
git checkout -f FETCH_HEAD
displayName: "Checkout vcpkg source"
displayName: "Checkout boost-math source"
5 changes: 0 additions & 5 deletions azure-devops/cmake-configure-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ parameters:
type: string
- name: targetArch
type: string
- name: vcpkgLocationVar
type: string
default: vcpkgLocation
- name: targetPlatform
type: string
- name: buildOutputLocationVar
Expand All @@ -33,8 +30,6 @@ steps:
call "%ProgramFiles%\Microsoft Visual Studio\2022\Preview\Common7\Tools\VsDevCmd.bat" ^
-host_arch=${{ parameters.hostArch }} -arch=${{ parameters.targetArch }} -no_logo
cmake ${{ parameters.cmakeAdditionalFlags}} -G Ninja ^
-DCMAKE_TOOLCHAIN_FILE=$(${{ parameters.vcpkgLocationVar }})\scripts\buildsystems\vcpkg.cmake ^
-DVCPKG_TARGET_TRIPLET=${{ parameters.targetPlatform }}-windows ^
-DCMAKE_CXX_COMPILER=cl ^
-DCMAKE_BUILD_TYPE=Release ^
-DLIT_FLAGS=$(litFlags) ^
Expand Down
3 changes: 0 additions & 3 deletions azure-devops/cross-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ jobs:
displayName: 'Setup TMP Directory'

- template: checkout-sources.yml
- template: vcpkg-dependencies.yml
parameters:
targetPlatform: ${{ parameters.targetPlatform }}
- template: cmake-configure-build.yml
parameters:
targetPlatform: ${{ parameters.targetPlatform }}
Expand Down
3 changes: 0 additions & 3 deletions azure-devops/native-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ jobs:
displayName: 'Setup TMP Directory'

- template: checkout-sources.yml
- template: vcpkg-dependencies.yml
parameters:
targetPlatform: ${{ parameters.targetPlatform }}
- template: cmake-configure-build.yml
parameters:
targetPlatform: ${{ parameters.targetPlatform }}
Expand Down
38 changes: 0 additions & 38 deletions azure-devops/vcpkg-dependencies.yml

This file was deleted.

1 change: 0 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
variables:
tmpDir: 'D:\Temp'
buildOutputLocation: 'D:\build'
vcpkgLocation: '$(Build.SourcesDirectory)/vcpkg'

pool: 'StlBuild-2021-08-11'

Expand Down
1 change: 1 addition & 0 deletions boost-math
Submodule boost-math added at 88c4b8
4 changes: 2 additions & 2 deletions stl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ function(add_stl_dlls D_SUFFIX THIS_CONFIG_DEFINITIONS THIS_CONFIG_COMPILE_OPTIO
add_library(msvcp_2${D_SUFFIX}_objects OBJECT ${SOURCES_SATELLITE_2})
target_compile_definitions(msvcp_2${D_SUFFIX}_objects PRIVATE "_BUILDING_SATELLITE_2;_DLL;${THIS_CONFIG_DEFINITIONS}")
target_compile_options(msvcp_2${D_SUFFIX}_objects PRIVATE "${THIS_CONFIG_COMPILE_OPTIONS};${GL_FLAG};/EHsc")
target_link_libraries(msvcp_2${D_SUFFIX}_objects PRIVATE Boost::headers Boost::disable_autolinking)
target_link_libraries(msvcp_2${D_SUFFIX}_objects PRIVATE Boost::math)

add_library(msvcp_2${D_SUFFIX} SHARED)
target_link_libraries(msvcp_2${D_SUFFIX} PRIVATE msvcp_2${D_SUFFIX}_objects msvcp${D_SUFFIX}_satellite_objects msvcp${D_SUFFIX}_implib_objects std_init_once_begin_initialize std_init_once_complete "msvcp${D_SUFFIX}" "${TOOLSET_LIB}/vcruntime${D_SUFFIX}.lib" "${TOOLSET_LIB}/msvcrt${D_SUFFIX}.lib" "ucrt${D_SUFFIX}.lib")
Expand Down Expand Up @@ -540,7 +540,7 @@ function(add_stl_statics FLAVOR_SUFFIX THIS_CONFIG_DEFINITIONS THIS_CONFIG_COMPI
add_library(libcpmt${FLAVOR_SUFFIX} STATIC ${HEADERS} ${IMPLIB_SOURCES} ${SOURCES} ${STATIC_SOURCES})
target_compile_definitions(libcpmt${FLAVOR_SUFFIX} PRIVATE "${THIS_CONFIG_DEFINITIONS}")
target_compile_options(libcpmt${FLAVOR_SUFFIX} PRIVATE "${THIS_CONFIG_COMPILE_OPTIONS};/EHsc")
target_link_libraries(libcpmt${FLAVOR_SUFFIX} PRIVATE Boost::headers Boost::disable_autolinking libcpmt${FLAVOR_SUFFIX}_eha std_init_once_begin_initialize std_init_once_complete)
target_link_libraries(libcpmt${FLAVOR_SUFFIX} PRIVATE Boost::math libcpmt${FLAVOR_SUFFIX}_eha std_init_once_begin_initialize std_init_once_complete)
endfunction()

add_stl_statics("" "_ITERATOR_DEBUG_LEVEL=0" "${VCLIBS_RELEASE_OPTIONS}")
Expand Down
2 changes: 1 addition & 1 deletion tools/validate/validate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ int main() {
L".vs"sv,
L".vscode"sv,
L"__pycache__"sv,
L"boost-math"sv,
L"build"sv,
L"llvm-project"sv,
L"out"sv,
L"vcpkg"sv,
};

static constexpr array skipped_extensions{
Expand Down
1 change: 0 additions & 1 deletion vcpkg
Submodule vcpkg deleted from 125735