Skip to content

Commit

Permalink
Support --sysroot= for ${arch}-windows-msvc targets
Browse files Browse the repository at this point in the history
I think it is possible to use the same rule for msvc targets with
--target= and --sysroot=

See Repository:
https://github.com/trcrsired/windows-msvc-sysroot

Add sysroot support for msvc

MSVC.cpp needs getDriver before using D

add stl in parser for -stdlib=

Add Vcruntime to runtime list and unwind list

MSVC add default runtime lib type and default unwind lib type

add a msvc sysroot test

use %S instead of /foo

Fix test for msvc-sysroot

Also add a pesudo implementation for WebAssembly and
maybe Microsoft STL could be ported to more targets in the future

Fix the toggle of wasm that prevents -stdlib=stl passed into
  • Loading branch information
trcrsired committed Jun 30, 2024
1 parent 038bc1c commit 3a78dfe
Show file tree
Hide file tree
Showing 8 changed files with 345 additions and 69 deletions.
9 changes: 6 additions & 3 deletions clang/include/clang/Driver/ToolChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,21 @@ class ToolChain {

enum CXXStdlibType {
CST_Libcxx,
CST_Libstdcxx
CST_Libstdcxx,
CST_Stl,
};

enum RuntimeLibType {
RLT_CompilerRT,
RLT_Libgcc
RLT_Libgcc,
RLT_Vcruntime
};

enum UnwindLibType {
UNW_None,
UNW_CompilerRT,
UNW_Libgcc
UNW_Libgcc,
UNW_Vcruntime
};

enum class UnwindTableLevel {
Expand Down
9 changes: 9 additions & 0 deletions clang/lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,8 @@ ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType(
runtimeLibType = ToolChain::RLT_CompilerRT;
else if (LibName == "libgcc")
runtimeLibType = ToolChain::RLT_Libgcc;
else if (LibName == "vcruntime")
runtimeLibType = ToolChain::RLT_Vcruntime;
else if (LibName == "platform")
runtimeLibType = GetDefaultRuntimeLibType();
else {
Expand Down Expand Up @@ -1129,6 +1131,8 @@ ToolChain::UnwindLibType ToolChain::GetUnwindLibType(
unwindLibType = ToolChain::UNW_CompilerRT;
} else if (LibName == "libgcc")
unwindLibType = ToolChain::UNW_Libgcc;
else if (LibName == "vcruntime")
unwindLibType = ToolChain::UNW_Vcruntime;
else {
if (A)
getDriver().Diag(diag::err_drv_invalid_unwindlib_name)
Expand All @@ -1152,6 +1156,8 @@ ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{
cxxStdlibType = ToolChain::CST_Libcxx;
else if (LibName == "libstdc++")
cxxStdlibType = ToolChain::CST_Libstdcxx;
else if (LibName == "stl")
cxxStdlibType = ToolChain::CST_Stl;
else if (LibName == "platform")
cxxStdlibType = GetDefaultCXXStdlibType();
else {
Expand Down Expand Up @@ -1290,6 +1296,9 @@ void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
case ToolChain::CST_Libstdcxx:
CmdArgs.push_back("-lstdc++");
break;

default:
break;
}
}

Expand Down
Loading

0 comments on commit 3a78dfe

Please sign in to comment.