Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ option(BUILD_TESTING "Enable testing" ON)
set(VCLIBS_SUFFIX "_oss" CACHE STRING "suffix for built DLL names to avoid conflicts with distributed DLLs")

option(STL_USE_ANALYZE "Pass the /analyze flag to MSVC" OFF)
option(STL_ASAN_BUILD "Build the STL with ASan enabled" OFF)

set(VCLIBS_EXPLICIT_MACHINE "")

Expand Down Expand Up @@ -117,10 +118,15 @@ set(VCLIBS_DEBUG_OPTIONS "$<$<COMPILE_LANGUAGE:CXX>:/Od>")
# See GH-2108 for more info.
set(VCLIBS_RELEASE_OPTIONS "$<$<COMPILE_LANGUAGE:CXX>:/O2;/Os>")

add_subdirectory(boost-math)
add_subdirectory(stl)

if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()

if(STL_ASAN_BUILD)
message(STATUS "Building with ASan enabled")
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-fsanitize=address;-fno-sanitize-address-vcasan-lib>")
endif()

add_subdirectory(boost-math)
add_subdirectory(stl)
2 changes: 2 additions & 0 deletions azure-devops/asan-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ stages:
targetPlatform: x64
vsDevCmdArch: amd64
buildBenchmarks: false
asanBuild: true
testSelection: ${{ variables.testSelection }}

- stage: Build_And_Test_x86
Expand All @@ -43,6 +44,7 @@ stages:
targetPlatform: x86
vsDevCmdArch: x86
buildBenchmarks: false
asanBuild: true
testSelection: ${{ variables.testSelection }}

# no coverage for ARM and ARM64
4 changes: 4 additions & 0 deletions azure-devops/cmake-configure-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ parameters:
type: string
- name: buildBenchmarks
type: boolean
- name: asanBuild
type: boolean
default: false
- name: cmakeAdditionalFlags
type: string
default: ''
Expand Down Expand Up @@ -43,6 +46,7 @@ steps:
-DCMAKE_BUILD_TYPE=Release ^
-DLIT_FLAGS=${{ join(';', parameters.litFlags) }} ^
-DSTL_USE_ANALYZE=ON ^
-DSTL_ASAN_BUILD=${{ parameters.asanBuild }} ^
-S $(Build.SourcesDirectory) -B "$(buildOutputLocation)"
displayName: 'Configure the STL'
timeoutInMinutes: 2
Expand Down
4 changes: 4 additions & 0 deletions azure-devops/native-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ parameters:
- name: buildBenchmarks
type: boolean
default: true
- name: asanBuild
type: boolean
default: false
- name: numShards
type: number
default: 8
Expand All @@ -35,6 +38,7 @@ jobs:
targetArch: ${{ parameters.vsDevCmdArch }}
hostArch: ${{ parameters.vsDevCmdArch }}
buildBenchmarks: ${{ parameters.buildBenchmarks }}
asanBuild: ${{ parameters.asanBuild }}
- template: run-tests.yml
parameters:
hostArch: ${{ parameters.vsDevCmdArch }}
Expand Down
8 changes: 7 additions & 1 deletion stl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,12 @@ else()
string(APPEND CMAKE_CXX_STANDARD_LIBRARIES " Synchronization.lib")
endif()

if(STL_ASAN_BUILD)
set(DLL_ASAN_SOURCES ${ASAN_SOURCES})
else()
set(DLL_ASAN_SOURCES "")
endif()

function(target_stl_compile_options tgt rel_or_dbg)
if(rel_or_dbg STREQUAL "Release")
target_compile_options(${tgt} PRIVATE ${VCLIBS_RELEASE_OPTIONS})
Expand Down Expand Up @@ -562,7 +568,7 @@ function(add_stl_dlls D_SUFFIX REL_OR_DBG)
set(gl_flag_Debug "")

# msvcp140.dll
add_library(msvcp${D_SUFFIX}_objects OBJECT ${DLL_SOURCES} ${SOURCES})
add_library(msvcp${D_SUFFIX}_objects OBJECT ${DLL_SOURCES} ${SOURCES} ${DLL_ASAN_SOURCES})
target_compile_definitions(msvcp${D_SUFFIX}_objects PRIVATE CRTDLL2 _DLL)
target_compile_options(msvcp${D_SUFFIX}_objects PRIVATE ${gl_flag_${REL_OR_DBG}} /EHsc)
target_stl_compile_options(msvcp${D_SUFFIX}_objects ${REL_OR_DBG})
Expand Down
3 changes: 2 additions & 1 deletion tests/libcxx/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ lit_config.library_dirs = getattr(lit_config, 'library_dirs', dict())
lit_config.test_subdirs = getattr(lit_config, 'test_subdirs', dict())

lit_config.expected_results[config.name] = stl.test.file_parsing.parse_result_file('@LIBCXX_EXPECTED_RESULTS@')
lit_config.include_dirs[config.name] = ['@STL_TESTED_HEADERS_DIR@', '@LIBCXX_SOURCE_DIR@/test/support']
# TRANSITION, VSO-1913897: '@STL_SOURCE_DIR@/tests/std/include' is a workaround
lit_config.include_dirs[config.name] = ['@STL_TESTED_HEADERS_DIR@', '@LIBCXX_SOURCE_DIR@/test/support', '@STL_SOURCE_DIR@/tests/std/include']
lit_config.library_dirs[config.name] = ['@STL_LIBRARY_OUTPUT_DIRECTORY@', '@TOOLSET_LIB@']
lit_config.test_subdirs[config.name] = ['@LIBCXX_SOURCE_DIR@/test/std']

Expand Down
2 changes: 1 addition & 1 deletion tests/libcxx/usual_matrix.lst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

RUNALL_INCLUDE ..\universal_prefix.lst
RUNALL_CROSSLIST
* PM_CL="/EHsc /MTd /std:c++latest /permissive- /utf-8 /FImsvc_stdlib_force_include.h /wd4643 /D_STL_CALL_ABORT_INSTEAD_OF_INVALID_PARAMETER"
* PM_CL="/EHsc /MTd /std:c++latest /permissive- /utf-8 /FImsvc_stdlib_force_include.h /FIvso1913897.hpp /wd4643 /D_STL_CALL_ABORT_INSTEAD_OF_INVALID_PARAMETER"
RUNALL_CROSSLIST
PM_CL="/analyze:autolog- /Zc:preprocessor /wd6262"
ASAN PM_CL="-fsanitize=address /Zi" PM_LINK="/debug"
Expand Down
2 changes: 2 additions & 0 deletions tests/std/include/force_include.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <stdio.h>
#include <stdlib.h>

#include "vso1913897.hpp"

struct TestEnvironmentPreparer {
TestEnvironmentPreparer() noexcept {
// avoid assertion dialog boxes; see GH-781
Expand Down
15 changes: 15 additions & 0 deletions tests/std/include/vso1913897.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#pragma once

#ifndef _M_CEE

// TRANSITION, dynamically initialize a thread_local to workaround VSO-1913897
inline int __stl_asan_init_function() {
static volatile int __stl_asan_init_volatile = 42;
return __stl_asan_init_volatile;
}
static thread_local int __stl_asan_init_variable = __stl_asan_init_function();

#endif // _M_CEE
2 changes: 1 addition & 1 deletion tests/std/tests/GH_002030_asan_annotate_string/env.lst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# This test matrix is the usual test matrix, with all currently unsupported options removed, crossed with the ASan flags.

# TRANSITION, google/sanitizers#328 - clang-cl does not currently support targeting /MDd or /MTd.
# TRANSITION, google/sanitizers#328: clang-cl does not support /MDd or /MTd with ASan
RUNALL_INCLUDE ..\prefix.lst
RUNALL_CROSSLIST
PM_CL="/Zi /wd4611 /w14640 /Zc:threadSafeInit-" PM_LINK="/debug"
Expand Down
2 changes: 1 addition & 1 deletion tests/std/tests/GH_002030_asan_annotate_vector/env.lst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# This test matrix is the usual test matrix, with all currently unsupported options removed, crossed with the ASan flags.

# TRANSITION, google/sanitizers#328 - clang-cl does not currently support targeting /MDd or /MTd.
# TRANSITION, google/sanitizers#328: clang-cl does not support /MDd or /MTd with ASan
RUNALL_INCLUDE ..\prefix.lst
RUNALL_CROSSLIST
PM_CL="/Zi /wd4611 /w14640 /Zc:threadSafeInit-" PM_LINK="/debug"
Expand Down
5 changes: 5 additions & 0 deletions tests/utils/stl/test/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ def configureTest(self, litConfig):
self.isenseRspPath = tmpBase + '.isense.rsp'
self.compileFlags.extend(['/dE--write-isense-rsp', '/dE' + self.isenseRspPath])

# TRANSITION, google/sanitizers#328: clang-cl does not support /MDd or /MTd with ASan
if ('clang' in self.config.available_features and 'asan' in self.config.available_features and
('MTd' in self.config.available_features or 'MDd' in self.config.available_features)):
return Result(UNSUPPORTED, 'clang does not support debug variants of the STL with ASan')

self._configureTestType()

forceFail = self.expectedResult and self.expectedResult.isFailure
Expand Down