This will allow selecting the microsoft C runtime library without having to use cc1 flags.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/include/clang/Driver/Options.td | ||
---|---|---|
2215 | Could this also list the allowed options? And maybe it could also have a DocBrief that explains how to use it? | |
clang/lib/Driver/ToolChains/Clang.cpp | ||
6546 | Could we somehow re-use the logic in Clang::AddClangCLArgs()? Perhaps the main switch from that could be extracted to a function that could be called from here? | |
clang/test/Driver/cl-runtime-flags.c | ||
107 | If we want these to behave as the /MD and /MT flags, maybe we can re-use the tests for those, so e.g. we'd do: // RUN: %clang_cl -### /MD -- %s 2>&1 | FileCheck -check-prefix=CHECK-MD %s // RUN: %clang -### -target ... -fms-runtime-lib=dll -- %s 2>&1 | FileCheck -check-prefix=CHECK-MD %s // CHECK-MD-NOT: "-D_DEBUG" // CHECK-MD: "-D_MT" // CHECK-MD: "-D_DLL" ... |
Clean up test, add doc brief to new flag, try to put the flag logic in a separate function
clang/lib/Driver/ToolChains/Clang.cpp | ||
---|---|---|
6546 | Put it in a separate function; I guess it's a bit messy as some clang-cl flags aren't implemented for clang. |
clang/lib/Driver/ToolChains/Clang.cpp | ||
---|---|---|
4443 | Could this be an enum, or reuse existing values like the /Mx option ids? | |
4444 | The IsClangCL && part seems redundant? | |
4446 | Should this use HasLDdFlag? | |
4462 | Is there a getLastArg() variant that allows getting the last argument of either the /Mx options or -fms-runtime-lib, so we don't need to check IsClangCL? |
clang/lib/Driver/ToolChains/Clang.cpp | ||
---|---|---|
6546 | Should this be Triple.isWindowsMSVCEnvironment()? We don't want to do this at least for the mingw/cygwin environments. |
LGTM from my perspective now too.
clang/lib/Driver/ToolChains/Clang.cpp | ||
---|---|---|
4493 | If I understand correctly, we still don't have any corresponding gcc style driver flag for this? Would you consider adding that in a separate, later patch? |
clang/lib/Driver/ToolChains/Clang.cpp | ||
---|---|---|
4493 | Yep, I can add that too. |
@akhuang I noticed that https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/MSVC.cpp#L199-L200 has got an explicit check for Args.hasArg(options::OPT__SLASH_MD, options::OPT__SLASH_MDd) - I think that this would need to be amended to handle these cases too - or is that inferred from here somehow?
You're right, those cases aren't being handled right now. I'll upload a patch for that.
Could this also list the allowed options? And maybe it could also have a DocBrief that explains how to use it?