Skip to content

[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

Merged
merged 1 commit into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/sycl-MD-default.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// RUN: %clangxx -### -fsycl -c -target x86_64-unknown-windows-msvc %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-DEFAULT %s
// CHK-DEFAULT-NOT: "-fsycl-is-device" {{.*}} "-D_MT" "-D_DLL"
// CHK-DEFAULT: "-fsycl-is-host"{{.*}} "-D_MT" "-D_DLL" "--dependent-lib=msvcrt{{d*}}" {{.*}}
// CHK-DEFAULT: "-fsycl-is-host"{{.*}} "-D_MT" "-D_DLL"

// RUN: %clang_cl -### -fsycl -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-DEFAULT-CL %s
Expand Down