-
Notifications
You must be signed in to change notification settings - Fork 768
[Driver][SYCL] Do not imply defaultlib msvcrt for Linux based driver on Windows #3827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When compiling for Windows target, we should only be adding the defaultlib msvcrt directive when performing MSVC compatible compilations. If adding msvcrt for Linux style compilations, we do not know if the library should be the regular library or the debug library, as that is determined by the use of /MD or /MDd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patch LGTM; I double @bader's request for @v-klochkov's input here (could be some context that I'm missing).
Always pulling in |
Why the description says "do not imply msvcrt for non-msvc Windows", while the change removes the msvcrt for msvc-windows? The change is done under 'if (AuxT.isWindowsMSVCEnvironment())' condition. |
@@ -4663,7 +4663,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, | |||
if (AuxT.isWindowsMSVCEnvironment()) { | |||
CmdArgs.push_back("-D_MT"); | |||
CmdArgs.push_back("-D_DLL"); | |||
CmdArgs.push_back("--dependent-lib=msvcrt"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is hard to tell, why the new code would work properly. It does not seem correct to me now.
The idea of the line that is removed here was to enforce dynamic MSVC RT with -fsycl switch for clang++ driver.
For CL mode the MSVC RT is set in addClangCLArgs() and CL allows either /MD (msvcrt) or /MDd (msvcrtd).
The line that was removed in this patch is for 'clang++' driver, which does not allow setting /MDd, and thus the only option for -fsycl is msvcrt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What RT is used in the patched compiler (i.e. clang++ -fsycl test.cpp)? If that is libcmt (which is by default), then there may be errors caused by using msvcrt in SYCL and libcmt in test.obj
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default library (msvcrt) used is passed to the link
step via -defaultlib
:
> clang++ -fsycl --target=x86_64-pc-windows-msvc ~/a.cpp -### 2>&1 | grep msvcrt "link.exe" "-out:a.exe" "-defaultlib:msvcrt" "-defaultlib:oldnames" "-defaultlib:sycl.lib" "/IGNORE:4078" "-libpath:lib/amd64" "-libpath:atlmfc/lib/amd64" "-nologo" "/tmp/a-ca1b1c.o" "/tmp/a-028002.o"
The use of the -defaultlib
option is used for clang++
and the embedded default directives are used for clang-cl
.
I still do not understand the motivation for the change.
clang++ does NOT accept /MDd switch and thus there is no way to use debug msvcrtd RT, right? I would think the RT library is always regular (even with -g). My other concern is that with the patch there is no even a warning telling user that something may go wrong if user compiles sources as below: NOW (without patch): With the patch: ksh-3.2$ clang++ test.o ../builds/xmainefi2win_prod/llvm/lib/sycl.lib -### 2>&1 | grep defaultlib |
Ok, I forgot about using "-Xclang --dependent-lib=msvcrtd", which is also correct usage and interferes with the implied msvcrt. |
@alexbatashev, ping. |
* sycl: (320 commits) [SYCL] Silence a "local variable is initialized but not referenced" warning; NFC (intel#3870) [SYCL] Improve SYCL_DEVICE_ALLOWLIST (intel#3826) [SPIR-V] Change return value of mapType function (intel#3871) [SYCL] Fix post-commit failure in handler.hpp from unused-parameters. (intel#3874) [Driver][SYCL] Do not imply defaultlib msvcrt for Linux based driver on Windows (intel#3827) [SYCL] Unique stable name rebase (intel#3835) [SYCL] Align behavior of empty command groups with SYCL2020 (intel#3822) [SYCL][ESIMD] Make typenames and constants consistent with SYCL API style. (intel#3850) [SYCL] Allow __failed_assertion to support libstdc++-11 (intel#3774) [SYCL] Refactor stream class handing implementation (intel#3646) [SYCL] Fix syntax error introduced in intel#3401 (intel#3861) [SYCL] SYCL 2020 sub_group algorithms (intel#3786) [Buildbot][NFC] Add option to use LLD as linker (intel#3866) Revert "Emit correct location lists with basic block sections." [SPIRITTAnnotations] Fix debug info for ITT calls. (intel#3829) [SYCL][Doc] Fix build of Sphinx docs (intel#3863) [SYCL][FPGA][NFC] Tidy up intel_fpga_reg codegen test (intel#3810) [CODEOWNERS] Fix SPIRITTAnnnotations tests ownership (intel#3859) [SYCL][ESIMD] Host-compile simd.cpp test, fix errors & warnings. (intel#3846) [SYCL] Store pointers to memory allocations instead of iterators (intel#3860) ...
When compiling for Windows target, we should only be adding the
defaultlib msvcrt directive when performing MSVC compatible compilations.
If adding msvcrt for Linux style compilations, we do not know if
the library should be the regular library or the debug library, as that
is determined by the use of /MD or /MDd.