diff --git a/compiler/src/dmd/cond.d b/compiler/src/dmd/cond.d index 386b20b658..02dde1b4c0 100644 --- a/compiler/src/dmd/cond.d +++ b/compiler/src/dmd/cond.d @@ -659,9 +659,9 @@ extern (C++) final class VersionCondition : DVCondition case "AVR": case "BigEndian": case "BSD": - case "CppRuntime_libcpp": + case "CppRuntime_LLVM": case "CppRuntime_DigitalMars": - case "CppRuntime_libstdcpp": + case "CppRuntime_GNU": case "CppRuntime_Microsoft": case "CppRuntime_Sun": case "CRuntime_Bionic": diff --git a/compiler/src/dmd/dmdparams.d b/compiler/src/dmd/dmdparams.d index a8b42e25e6..af24b87a18 100644 --- a/compiler/src/dmd/dmdparams.d +++ b/compiler/src/dmd/dmdparams.d @@ -298,10 +298,12 @@ struct Triple { with (TargetCPP.Runtime) switch (cppenv) { - case "libcpp": return libcpp; - case "libstdcpp": return libstdcpp; - case "clang": return libcpp; // legacy option - case "gcc": return libstdcpp; // legacy option + case "libc++": return LLVM; + case "libstdc++": return GNU; + case "libcxx": return LLVM; + case "libstdcxx": return GNU; + case "clang": return LLVM; // legacy option + case "gcc": return GNU; // legacy option case "msvc": return Microsoft; case "sun": return Sun; default: diff --git a/compiler/src/dmd/frontend.h b/compiler/src/dmd/frontend.h index 0d0ef4ee18..d22cf87517 100644 --- a/compiler/src/dmd/frontend.h +++ b/compiler/src/dmd/frontend.h @@ -5994,8 +5994,8 @@ struct TargetCPP final enum class Runtime : uint8_t { Unspecified = 0u, - libcpp = 1u, - libstdcpp = 2u, + LLVM = 1u, + GNU = 2u, Microsoft = 3u, Sun = 4u, }; diff --git a/compiler/src/dmd/target.d b/compiler/src/dmd/target.d index 60c7f5ef28..797ff5bead 100644 --- a/compiler/src/dmd/target.d +++ b/compiler/src/dmd/target.d @@ -270,12 +270,12 @@ void addCppRuntimePredefinedGlobalIdent(const ref TargetCPP cpp) default: case Unspecified: return; - case libcpp: - predef("CppRuntime_libcpp"); + case LLVM: + predef("CppRuntime_LLVM"); predef("CppRuntime_Clang"); // legacy return; - case libstdcpp: - predef("CppRuntime_libstdcpp"); + case GNU: + predef("CppRuntime_GNU"); predef("CppRuntime_Gcc"); // legacy return; case Microsoft: @@ -1465,8 +1465,8 @@ struct TargetCPP enum Runtime : ubyte { Unspecified, - libcpp, - libstdcpp, + LLVM, + GNU, Microsoft, Sun } @@ -1495,11 +1495,11 @@ struct TargetCPP if (os == Target.OS.Windows) runtime = Runtime.Microsoft; else if (os & (Target.OS.linux | Target.OS.DragonFlyBSD)) - runtime = Runtime.libstdcpp; + runtime = Runtime.GNU; else if (os & (Target.OS.OSX | Target.OS.FreeBSD | Target.OS.OpenBSD)) - runtime = Runtime.libcpp; + runtime = Runtime.LLVM; else if (os == Target.OS.Solaris) - runtime = Runtime.libstdcpp; + runtime = Runtime.GNU; else assert(0); // C++ and D ABI incompatible on all (?) x86 32-bit platforms diff --git a/compiler/src/dmd/target.h b/compiler/src/dmd/target.h index 88583929eb..a380bb8bbe 100644 --- a/compiler/src/dmd/target.h +++ b/compiler/src/dmd/target.h @@ -84,8 +84,8 @@ struct TargetCPP enum class Runtime : unsigned char { Unspecified, - libcpp, - libstdcpp, + LLVM, + GNU, Microsoft, Sun }; diff --git a/compiler/test/compilable/cppmangle.d b/compiler/test/compilable/cppmangle.d index 86c0705a2c..4b9046e811 100644 --- a/compiler/test/compilable/cppmangle.d +++ b/compiler/test/compilable/cppmangle.d @@ -7,8 +7,8 @@ import core.stdc.stdio; -version (CppRuntime_libcpp) version = CppMangle_Itanium; -version (CppRuntime_libstdcpp) version = CppMangle_Itanium; +version (CppRuntime_LLVM) version = CppMangle_Itanium; +version (CppRuntime_GNU) version = CppMangle_Itanium; version (CppRuntime_Microsoft) version = CppMangle_MSVC; version (CppRuntime_Sun) version = CppMangle_Itanium; diff --git a/compiler/test/compilable/cppmangle3.d b/compiler/test/compilable/cppmangle3.d index 6cb593e53e..94de1fa9ff 100644 --- a/compiler/test/compilable/cppmangle3.d +++ b/compiler/test/compilable/cppmangle3.d @@ -3,8 +3,8 @@ // https://issues.dlang.org/show_bug.cgi?id=19920 module cppmangle3; -version (CppRuntime_libcpp) version = CppMangle_Itanium; -version (CppRuntime_libstdcpp) version = CppMangle_Itanium; +version (CppRuntime_LLVM) version = CppMangle_Itanium; +version (CppRuntime_GNU) version = CppMangle_Itanium; version (CppRuntime_Microsoft) version = CppMangle_MSVC; version (CppRuntime_Sun) version = CppMangle_Itanium; diff --git a/compiler/test/compilable/issue21203.d b/compiler/test/compilable/issue21203.d index ad503da340..ee394b310a 100644 --- a/compiler/test/compilable/issue21203.d +++ b/compiler/test/compilable/issue21203.d @@ -1,5 +1,5 @@ -version (CppRuntime_libcpp) version = CppMangle_Itanium; -version (CppRuntime_libstdcpp) version = CppMangle_Itanium; +version (CppRuntime_LLVM) version = CppMangle_Itanium; +version (CppRuntime_GNU) version = CppMangle_Itanium; version (CppRuntime_Sun) version = CppMangle_Itanium; template ScopeClass(C , string name = C.stringof) diff --git a/compiler/test/compilable/issue21340.d b/compiler/test/compilable/issue21340.d index a197258d19..2628099869 100644 --- a/compiler/test/compilable/issue21340.d +++ b/compiler/test/compilable/issue21340.d @@ -1,5 +1,5 @@ -version (CppRuntime_libcpp) version = CppMangle_Itanium; -version (CppRuntime_libstdcpp) version = CppMangle_Itanium; +version (CppRuntime_LLVM) version = CppMangle_Itanium; +version (CppRuntime_GNU) version = CppMangle_Itanium; version (CppRuntime_Sun) version = CppMangle_Itanium; template ScopeClass(C) diff --git a/compiler/test/fail_compilation/reserved_version.d b/compiler/test/fail_compilation/reserved_version.d index 44dd46af5b..502ae4a5bc 100644 --- a/compiler/test/fail_compilation/reserved_version.d +++ b/compiler/test/fail_compilation/reserved_version.d @@ -110,9 +110,9 @@ fail_compilation/reserved_version.d(211): Error: version identifier `AsmJS` is r fail_compilation/reserved_version.d(212): Error: version identifier `Emscripten` is reserved and cannot be set fail_compilation/reserved_version.d(213): Error: version identifier `WebAssembly` is reserved and cannot be set fail_compilation/reserved_version.d(214): Error: version identifier `WASI` is reserved and cannot be set -fail_compilation/reserved_version.d(215): Error: version identifier `CppRuntime_libcpp` is reserved and cannot be set +fail_compilation/reserved_version.d(215): Error: version identifier `CppRuntime_LLVM` is reserved and cannot be set fail_compilation/reserved_version.d(216): Error: version identifier `CppRuntime_DigitalMars` is reserved and cannot be set -fail_compilation/reserved_version.d(217): Error: version identifier `CppRuntime_libstdcpp` is reserved and cannot be set +fail_compilation/reserved_version.d(217): Error: version identifier `CppRuntime_GNU` is reserved and cannot be set fail_compilation/reserved_version.d(218): Error: version identifier `CppRuntime_Microsoft` is reserved and cannot be set fail_compilation/reserved_version.d(219): Error: version identifier `CppRuntime_Sun` is reserved and cannot be set fail_compilation/reserved_version.d(220): Error: version identifier `D_PIE` is reserved and cannot be set @@ -239,9 +239,9 @@ version = AsmJS; version = Emscripten; version = WebAssembly; version = WASI; -version = CppRuntime_libcpp; +version = CppRuntime_LLVM; version = CppRuntime_DigitalMars; -version = CppRuntime_libstdcpp; +version = CppRuntime_GNU; version = CppRuntime_Microsoft; version = CppRuntime_Sun; version = D_PIE; @@ -339,9 +339,9 @@ debug = CRuntime_Musl; debug = CRuntime_Newlib; debug = CRuntime_UClibc; debug = CRuntime_WASI; -debug = CppRuntime_libcpp; +debug = CppRuntime_LLVM; debug = CppRuntime_DigitalMars; -debug = CppRuntime_libstdcpp; +debug = CppRuntime_GNU; debug = CppRuntime_Microsoft; debug = CppRuntime_Sun; debug = D_Coverage; diff --git a/compiler/test/fail_compilation/reserved_version_switch.d b/compiler/test/fail_compilation/reserved_version_switch.d index 57be6e3502..2b6bb5e535 100644 --- a/compiler/test/fail_compilation/reserved_version_switch.d +++ b/compiler/test/fail_compilation/reserved_version_switch.d @@ -86,9 +86,9 @@ // REQUIRED_ARGS: -version=CRuntime_Newlib // REQUIRED_ARGS: -version=CRuntime_UClibc // REQUIRED_ARGS: -version=CRuntime_WASI -// REQUIRED_ARGS: -version=CppRuntime_libcpp +// REQUIRED_ARGS: -version=CppRuntime_LLVM // REQUIRED_ARGS: -version=CppRuntime_DigitalMars -// REQUIRED_ARGS: -version=CppRuntime_libstdcpp +// REQUIRED_ARGS: -version=CppRuntime_GNU // REQUIRED_ARGS: -version=CppRuntime_Microsoft // REQUIRED_ARGS: -version=CppRuntime_Sun // REQUIRED_ARGS: -version=D_Coverage @@ -195,9 +195,9 @@ // REQUIRED_ARGS: -debug=CRuntime_Newlib // REQUIRED_ARGS: -debug=CRuntime_UClibc // REQUIRED_ARGS: -debug=CRuntime_WASI -// REQUIRED_ARGS: -debug=CppRuntime_libcpp +// REQUIRED_ARGS: -debug=CppRuntime_LLVM // REQUIRED_ARGS: -debug=CppRuntime_DigitalMars -// REQUIRED_ARGS: -debug=CppRuntime_libstdcpp +// REQUIRED_ARGS: -debug=CppRuntime_GNU // REQUIRED_ARGS: -debug=CppRuntime_Microsoft // REQUIRED_ARGS: -debug=CppRuntime_Sun // REQUIRED_ARGS: -debug=D_Coverage @@ -310,9 +310,9 @@ Error: version identifier `CRuntime_Musl` is reserved and cannot be set Error: version identifier `CRuntime_Newlib` is reserved and cannot be set Error: version identifier `CRuntime_UClibc` is reserved and cannot be set Error: version identifier `CRuntime_WASI` is reserved and cannot be set -Error: version identifier `CppRuntime_libcpp` is reserved and cannot be set +Error: version identifier `CppRuntime_LLVM` is reserved and cannot be set Error: version identifier `CppRuntime_DigitalMars` is reserved and cannot be set -Error: version identifier `CppRuntime_libstdcpp` is reserved and cannot be set +Error: version identifier `CppRuntime_GNU` is reserved and cannot be set Error: version identifier `CppRuntime_Microsoft` is reserved and cannot be set Error: version identifier `CppRuntime_Sun` is reserved and cannot be set Error: version identifier `D_Coverage` is reserved and cannot be set diff --git a/compiler/test/runnable_cxx/cpp_stdlib.d b/compiler/test/runnable_cxx/cpp_stdlib.d index 007a5929e7..5b7d00a381 100644 --- a/compiler/test/runnable_cxx/cpp_stdlib.d +++ b/compiler/test/runnable_cxx/cpp_stdlib.d @@ -5,7 +5,7 @@ import core.stdc.stdio; // Disabled on windows because it needs bindings -version (CppRuntime_libcpp) +version (CppRuntime_LLVM) { extern(C++, `std`, `__1`) { diff --git a/compiler/test/runnable_cxx/cppa.d b/compiler/test/runnable_cxx/cppa.d index 22f5ec0f11..c62bc6face 100644 --- a/compiler/test/runnable_cxx/cppa.d +++ b/compiler/test/runnable_cxx/cppa.d @@ -455,7 +455,7 @@ extern (C++, std) { } - version (CppRuntime_libstdcpp) + version (CppRuntime_GNU) { // https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html static if (__traits(getTargetInfo, "cppStd") >= 201103) diff --git a/compiler/test/tools/d_do_test.d b/compiler/test/tools/d_do_test.d index 2a74dc24cd..aef18ec180 100755 --- a/compiler/test/tools/d_do_test.d +++ b/compiler/test/tools/d_do_test.d @@ -212,9 +212,9 @@ immutable(EnvData) processEnvironment() { case "dmd": case "ldc": - version (CppRuntime_libstdcpp) + version (CppRuntime_GNU) envData.cxxCompatFlags = " -L-lstdc++ -L--no-demangle"; - else version (CppRuntime_libcpp) + else version (CppRuntime_LLVM) envData.cxxCompatFlags = " -L-lc++ -L--no-demangle"; else version (CppRuntime_Gcc) envData.cxxCompatFlags = " -L-lstdc++ -L--no-demangle"; diff --git a/compiler/test/unit/triple.d b/compiler/test/unit/triple.d index f71b8826e4..72ca86f828 100644 --- a/compiler/test/unit/triple.d +++ b/compiler/test/unit/triple.d @@ -37,14 +37,24 @@ unittest assert(triple.cpu == CPU.avx2); } -@("-target=x86_64-unknown-linux-musl-libcpp") +@("-target=x86_64-unknown-linux-musl-libcxx") unittest { - auto triple = Triple("x86_64-unknown-linux-musl-libcpp"); + auto triple = Triple("x86_64-unknown-linux-musl-libcxx"); assert(triple.isX86_64 == true); assert(triple.os == Target.OS.linux); assert(triple.cenv == TargetC.Runtime.Musl); - assert(triple.cppenv == TargetCPP.Runtime.libcpp); + assert(triple.cppenv == TargetCPP.Runtime.LLVM); +} + +@("-target=x86_64-unknown-linux-musl-libc++") +unittest +{ + auto triple = Triple("x86_64-unknown-linux-musl-libc++"); + assert(triple.isX86_64 == true); + assert(triple.os == Target.OS.linux); + assert(triple.cenv == TargetC.Runtime.Musl); + assert(triple.cppenv == TargetCPP.Runtime.LLVM); } @("-target=x86_64-freebsd12") diff --git a/druntime/src/core/stdcpp/allocator.d b/druntime/src/core/stdcpp/allocator.d index e38ec22f83..a574cd39e8 100644 --- a/druntime/src/core/stdcpp/allocator.d +++ b/druntime/src/core/stdcpp/allocator.d @@ -147,7 +147,7 @@ extern(D): /// enum size_t max_size = size_t.max / T.sizeof; } - else version (CppRuntime_libstdcpp) + else version (CppRuntime_GNU) { /// T* allocate(size_t count, const(void)* = null) @nogc @@ -174,7 +174,7 @@ extern(D): /// enum size_t max_size = (ptrdiff_t.max < size_t.max ? cast(size_t)ptrdiff_t.max : size_t.max) / T.sizeof; } - else version (CppRuntime_libcpp) + else version (CppRuntime_LLVM) { /// T* allocate(size_t count, const(void)* = null) @nogc @@ -360,7 +360,7 @@ version (CppRuntime_Microsoft) } } } -version (CppRuntime_libcpp) +version (CppRuntime_LLVM) { // Helper for container swap package(core.stdcpp) void __swap_allocator(Alloc)(ref Alloc __a1, ref Alloc __a2) diff --git a/druntime/src/core/stdcpp/array.d b/druntime/src/core/stdcpp/array.d index 492abcea44..912587c6c7 100644 --- a/druntime/src/core/stdcpp/array.d +++ b/druntime/src/core/stdcpp/array.d @@ -74,7 +74,7 @@ pure nothrow @nogc: private: T[N ? N : 1] _Elems; } - else version (CppRuntime_libstdcpp) + else version (CppRuntime_GNU) { /// inout(T)* data() inout @safe { static if (N > 0) { return &_M_elems[0]; } else { return null; } } @@ -94,7 +94,7 @@ pure nothrow @nogc: _Placeholder _M_placeholder; } } - else version (CppRuntime_libcpp) + else version (CppRuntime_LLVM) { /// inout(T)* data() inout @trusted { static if (N > 0) { return &__elems_[0]; } else { return cast(inout(T)*)__elems_.ptr; } } diff --git a/druntime/src/core/stdcpp/exception.d b/druntime/src/core/stdcpp/exception.d index cf48f119f9..bd3be0937f 100644 --- a/druntime/src/core/stdcpp/exception.d +++ b/druntime/src/core/stdcpp/exception.d @@ -15,9 +15,9 @@ module core.stdcpp.exception; import core.stdcpp.xutility : __cplusplus, CppStdRevision; import core.attribute : weak; -version (CppRuntime_libstdcpp) +version (CppRuntime_GNU) version = GenericBaseException; -version (CppRuntime_libcpp) +version (CppRuntime_LLVM) version = GenericBaseException; version (CppRuntime_Sun) version = GenericBaseException; diff --git a/druntime/src/core/stdcpp/memory.d b/druntime/src/core/stdcpp/memory.d index 1a1a767ae5..d7b6f17387 100644 --- a/druntime/src/core/stdcpp/memory.d +++ b/druntime/src/core/stdcpp/memory.d @@ -123,7 +123,7 @@ nothrow pure @safe @nogc: _Compressed_pair!(Deleter, pointer) _Mypair; } - else version (CppRuntime_libstdcpp) + else version (CppRuntime_GNU) { /// ref inout(deleter_type) get_deleter() inout nothrow { return _M_t.get!1; } @@ -136,7 +136,7 @@ nothrow pure @safe @nogc: tuple!(pointer, Deleter) _M_t; } - else version (CppRuntime_libcpp) + else version (CppRuntime_LLVM) { /// ref inout(deleter_type) get_deleter() inout nothrow { return __ptr_.second; } diff --git a/druntime/src/core/stdcpp/string.d b/druntime/src/core/stdcpp/string.d index 257372fe53..0315867da6 100644 --- a/druntime/src/core/stdcpp/string.d +++ b/druntime/src/core/stdcpp/string.d @@ -31,7 +31,7 @@ version (Darwin) version = _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT; } -version (CppRuntime_libstdcpp) +version (CppRuntime_GNU) { version (_GLIBCXX_USE_CXX98_ABI) { @@ -894,7 +894,7 @@ extern(D): _String_alloc!(_String_base_types!(T, Alloc)) _Base; } - else version (CppRuntime_libstdcpp) + else version (CppRuntime_GNU) { version (_GLIBCXX_USE_CXX98_ABI) { @@ -1873,7 +1873,7 @@ extern(D): __d[0 .. __n] = __s[0 .. __n]; } } - else version (CppRuntime_libcpp) + else version (CppRuntime_LLVM) { //---------------------------------------------------------------------------------- // libc++ implementation diff --git a/druntime/src/core/stdcpp/string_view.d b/druntime/src/core/stdcpp/string_view.d index 981b06b183..fd79a121be 100644 --- a/druntime/src/core/stdcpp/string_view.d +++ b/druntime/src/core/stdcpp/string_view.d @@ -99,7 +99,7 @@ private: alias __data = _Mydata; alias __size = _Mysize; } - else version (CppRuntime_libstdcpp) + else version (CppRuntime_GNU) { size_t _M_len; const(T)* _M_str; @@ -107,7 +107,7 @@ private: alias __data = _M_str; alias __size = _M_len; } - else version (CppRuntime_libcpp) + else version (CppRuntime_LLVM) { const value_type* __data; size_type __size; diff --git a/druntime/src/core/stdcpp/typeinfo.d b/druntime/src/core/stdcpp/typeinfo.d index 84478c3c57..463a813bc9 100644 --- a/druntime/src/core/stdcpp/typeinfo.d +++ b/druntime/src/core/stdcpp/typeinfo.d @@ -56,7 +56,7 @@ version (CppRuntime_Microsoft) //virtual ~this(); } } -else version (CppRuntime_libstdcpp) +else version (CppRuntime_GNU) { import core.stdcpp.exception; @@ -110,7 +110,7 @@ else version (CppRuntime_libstdcpp) @weak override const(char)* what() const nothrow { return "bad typeid"; } } } -else version (CppRuntime_libcpp) +else version (CppRuntime_LLVM) { import core.stdcpp.exception; diff --git a/druntime/src/core/stdcpp/xutility.d b/druntime/src/core/stdcpp/xutility.d index 5d88b86b55..5e2e711ba6 100644 --- a/druntime/src/core/stdcpp/xutility.d +++ b/druntime/src/core/stdcpp/xutility.d @@ -13,7 +13,7 @@ module core.stdcpp.xutility; @nogc: -version (CppRuntime_libcpp) +version (CppRuntime_LLVM) { import core.internal.traits : AliasSeq; enum StdNamespace = AliasSeq!("std", "__1"); @@ -349,7 +349,7 @@ package: void _Xoverflow_error(const(char)* message) nothrow; void _Xruntime_error(const(char)* message) nothrow; } -else version (CppRuntime_libcpp) +else version (CppRuntime_LLVM) { import core.stdcpp.type_traits : is_empty; @@ -379,7 +379,7 @@ extern(C++, "std"): @property ref inout(_T2) __value2_() inout nothrow @trusted @nogc { return *__get_base2(); } } } -version (CppRuntime_libstdcpp) +version (CppRuntime_GNU) { import core.atomic;