This is an archive of the discontinued LLVM Phabricator instance.

[CUDA] Allow using -o with -fsyntax-only
ClosedPublic

Authored by tra on Sep 1 2022, 11:29 AM.

Details

Summary

-fsyntax-only breaks down CUDA compilation pipeline and make it look like
multiple independent subcompilations and that trips the multiple arguments check
when -o is specified.

We do want to allow -fsyntax-only to be used with otherwise unmodified clang
options as it's commonly used by various tooling.

Diff Detail

Event Timeline

tra created this revision.Sep 1 2022, 11:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2022, 11:29 AM
tra updated this revision to Diff 457341.Sep 1 2022, 11:55 AM

Added a test.

tra updated this revision to Diff 457343.Sep 1 2022, 11:59 AM

Added new driver tests.

tra published this revision for review.Sep 1 2022, 12:01 PM
tra added reviewers: jhuber6, yaxunl.
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2022, 12:01 PM
jhuber6 accepted this revision.Sep 1 2022, 12:37 PM

LG, thanks.

clang/lib/Driver/Driver.cpp
4555

Might be cleaner since we only use this once and it's explained by the comment above, up to you.

This revision is now accepted and ready to land.Sep 1 2022, 12:37 PM
yaxunl added inline comments.Sep 1 2022, 12:48 PM
clang/test/Driver/cuda-bindings.cu
99

should we check there is no binding for Assembler and Linker?

tra added inline comments.Sep 1 2022, 1:04 PM
clang/test/Driver/cuda-bindings.cu
99

@jhuber6 : Interestingly enough, this exposed what looks like an issue with the new driver -- it will apparently attempt to run linker on empty inputs.
I believe it's an issue independent of this patch and will need to be fixed separately.

bin/clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 --offload-new-driver /usr/local/google/home/tra/work/llvm/repo/clang/test/Driver/cuda-bindings.cu
# "nvptx64-nvidia-cuda" - "clang", inputs: ["clang/test/Driver/cuda-bindings.cu"], output: (nothing)
# "nvptx64-nvidia-cuda" - "clang", inputs: ["clang/test/Driver/cuda-bindings.cu"], output: (nothing)
# "nvptx64-nvidia-cuda" - "NVPTX::Linker", inputs: [(nothing), (nothing)], output: "/tmp/cuda-bindings-0bbbdf.fatbin"
# "powerpc64le-ibm-linux-gnu" - "clang", inputs: ["clang/test/Driver/cuda-bindings.cu", "/tmp/cuda-bindings-0bbbdf.fatbin"], output: (nothing)
tra updated this revision to Diff 457377.Sep 1 2022, 1:20 PM

Updated tests and addressed comments.

tra marked an inline comment as done.Sep 1 2022, 1:25 PM
tra added inline comments.
clang/test/Driver/cuda-bindings.cu
99

-fsyntax-only indeed crashes the new driver: https://godbolt.org/z/vqs4b8Mv1

jhuber6 added inline comments.Sep 1 2022, 1:40 PM
clang/test/Driver/cuda-bindings.cu
99

Yeah it seems to be because we don't quit when there's a TY_Nothing output. The expected behaviour of fsyntax-only should have no output, but we use the output from some previous phases when we build. Will need to find a way to still run both the host and device phases without input.

This revision was landed with ongoing or failed builds.Sep 1 2022, 3:53 PM
This revision was automatically updated to reflect the committed changes.
tra marked an inline comment as done.