-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compiler bug workaround for using
format()
in a user-defined module (…
- Loading branch information
1 parent
3cf597e
commit 0b6e350
Showing
11 changed files
with
127 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,4 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
RUNALL_INCLUDE ..\..\..\universal_prefix.lst | ||
RUNALL_CROSSLIST | ||
* PM_CL="/w14365 /D_ENFORCE_FACET_SPECIALIZATIONS=1 /D_STL_CALL_ABORT_INSTEAD_OF_INVALID_PARAMETER /Zc:preprocessor" | ||
RUNALL_CROSSLIST | ||
* PM_CL="/w14640 /Zc:threadSafeInit- /EHsc /DTEST_STANDARD=20 /std:c++20" | ||
* PM_CL="/w14640 /Zc:threadSafeInit- /EHsc /DTEST_STANDARD=23 /std:c++latest" | ||
RUNALL_CROSSLIST | ||
* PM_CL="/MD" | ||
* PM_CL="/MDd" | ||
* PM_CL="/MT" | ||
* PM_CL="/MTd" | ||
* PM_CL="/MDd /analyze:only /analyze:autolog-" | ||
* PM_CL="/MDd /GR- /D_HAS_STATIC_RTTI=0" | ||
* PM_CL="/MDd /utf-8" | ||
RUNALL_CROSSLIST | ||
PM_CL="" | ||
ASAN PM_CL="-fsanitize=address /Zi" PM_LINK="/debug" | ||
RUNALL_INCLUDE ..\modules_20_matrix.lst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
29 changes: 29 additions & 0 deletions
29
tests/std/tests/VSO_1775715_user_defined_modules/custom_format.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
import os | ||
|
||
from stl.test.format import STLTestFormat, TestStep | ||
from stl.test.tests import TestType | ||
|
||
|
||
class CustomTestFormat(STLTestFormat): | ||
def getBuildSteps(self, test, litConfig, shared): | ||
_, outputBase = test.getTempPaths() | ||
|
||
testCpp = test.getSourcePath() | ||
sourceDir = os.path.dirname(testCpp) | ||
userIxx = os.path.join(sourceDir, 'user.ixx') | ||
|
||
# Dependency order is important here: | ||
inputPaths = [userIxx, testCpp] | ||
|
||
cmd = [test.cxx, *inputPaths, *test.flags, *test.compileFlags] | ||
|
||
if TestType.COMPILE in test.testType: | ||
cmd += ['/c'] | ||
elif TestType.RUN in test.testType: | ||
shared.execFile = f'{outputBase}.exe' | ||
cmd += [f'/Fe{shared.execFile}', '/link', *test.linkFlags] | ||
|
||
yield TestStep(cmd, shared.execDir, shared.env, False) |
18 changes: 18 additions & 0 deletions
18
tests/std/tests/VSO_1775715_user_defined_modules/custombuild.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Run; | ||
|
||
sub CustomBuildHook() | ||
{ | ||
my $cwd = Run::GetCWDName(); | ||
|
||
# Dependency order is important here: | ||
my @inputPaths = ("user.ixx", "test.cpp"); | ||
|
||
Run::ExecuteCL(join(" ", @inputPaths, "/Fe$cwd.exe")); | ||
} | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
RUNALL_INCLUDE ..\modules_20_matrix.lst |
9 changes: 9 additions & 0 deletions
9
tests/std/tests/VSO_1775715_user_defined_modules/lit.local.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
import os | ||
import site | ||
site.addsitedir(os.path.dirname(os.path.dirname(__file__))) | ||
import VSO_1775715_user_defined_modules.custom_format | ||
|
||
config.test_format = VSO_1775715_user_defined_modules.custom_format.CustomTestFormat() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
// Note: To properly test the fix for VSO-1775715, don't include any headers here. | ||
|
||
import User; | ||
|
||
int main() { | ||
user::prepare_test_environment(); | ||
user::test_vso_1775715(0, "0 0 0b0 0B0 0x0 0X0 0"); | ||
user::test_vso_1775715(77, "77 77 0b1001101 0B1001101 0x4d 0X4D 0115"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
module; | ||
|
||
#include <cassert> | ||
#include <format> | ||
#include <string> | ||
|
||
#include <force_include.hpp> | ||
|
||
export module User; | ||
|
||
namespace user { | ||
export void prepare_test_environment() { | ||
assert(test_environment_preparer.succeeded()); | ||
} | ||
|
||
// DevCom-10313766 VSO-1775715 "Using std::format in a module | ||
// requires including <format> header in .cpp files using that module" | ||
export template <class T> | ||
void test_vso_1775715(const T& value, const char* const expected_str) { | ||
const std::string actual_str = std::format("{0:#} {0:#d} {0:#b} {0:#B} {0:#x} {0:#X} {0:#o}", value); | ||
assert(actual_str == expected_str); | ||
} | ||
} // namespace user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
RUNALL_INCLUDE ..\..\universal_prefix.lst | ||
RUNALL_CROSSLIST | ||
* PM_CL="/w14365 /D_ENFORCE_FACET_SPECIALIZATIONS=1 /D_STL_CALL_ABORT_INSTEAD_OF_INVALID_PARAMETER /Zc:preprocessor" | ||
RUNALL_CROSSLIST | ||
* PM_CL="/w14640 /Zc:threadSafeInit- /EHsc /DTEST_STANDARD=20 /std:c++20" | ||
* PM_CL="/w14640 /Zc:threadSafeInit- /EHsc /DTEST_STANDARD=23 /std:c++latest" | ||
RUNALL_CROSSLIST | ||
* PM_CL="/MD" | ||
* PM_CL="/MDd" | ||
* PM_CL="/MT" | ||
* PM_CL="/MTd" | ||
* PM_CL="/MDd /analyze:only /analyze:autolog-" | ||
* PM_CL="/MDd /GR- /D_HAS_STATIC_RTTI=0" | ||
* PM_CL="/MDd /utf-8" | ||
RUNALL_CROSSLIST | ||
PM_CL="" | ||
ASAN PM_CL="-fsanitize=address /Zi" PM_LINK="/debug" |