Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[clang-cl] Accept cl-style output arguments (/Fo, -Fo) for --precompile #121046

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
Loading
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add a test for the -fmodule-output BMI output file
  • Loading branch information
sharadhr committed Apr 16, 2025
commit 59dcf4d9c9218bfbf6da3b7a3b99c055707d477b
8 changes: 8 additions & 0 deletions 8 clang/test/Driver/cl-cxx20-modules.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@

//--- test.pcm
// CPP20WARNING-NOT: clang-cl: warning: argument unused during compilation: '/std:c++20' [-Wunused-command-line-argument]

// test whether the following outputs %Hello.bmi
// RUN: %clang_cl /std:c++20 --precompile -x c++-module -fmodule-output=%t/Hello.bmi -Fo"%t/Hello.bmi" -c %t/Hello.cppm -### 2>&1 | FileCheck %s
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just one invocation, but the logic in GetNamedOutputPath() seems to cover many cases.

Also, is it -fmodule-output or /Fo that sets the output filename (or both?)

(Nit: you'll want to put -- before %t/Hello.cppm, otherwise it may be interpreted as a command-line option e.g. if the path starts with /Users.)

Copy link
Contributor Author

@sharadhr sharadhr Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just one invocation, but the logic in GetNamedOutputPath() seems to cover many cases.

Agreed; once again; open to suggestions for more test cases.

Also, is it -fmodule-output or /Fo that sets the output filename (or both?)

From the Clang user guide, it appears both are required, and CMake in particular uses the 'one-phase compilation' method.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the doc:

To generate a BMI for an importable module unit, use either the --precompile or -fmodule-output command line options.

Your test uses both, with the same filename passed to two different flags. This seems wrong to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming back after a long while...

Both arguments were provided to exercise CMake's command-line invocation which given this information might be incorrect.

@ChuanqiXu9 are you able to provide more information?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for ignoring this. --precompile will be meaningless if it is followed by a -c. So the command line in cmake's thread actually use -fmodule-output.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't worry too much about what CMake's command-line invocations linked above are doing. CMake doesn't yet support modules with clang-cl, and is waiting on the work here. The command lines I posted over there are showing what unmerged changes to CMake are doing in its test suite as part of analyzing why not everything is working. This PR should focus on the functionality in clang-cl and its test should focus on the documented and intended usage. Once this is merged then CMake can be taught to do the right thing.

// CHECK: "-emit-module-interface"
// CHECK: "-o" "{{.*}}Hello.bmi"

//--- Hello.cppm
export module Hello;
Morty Proxy This is a proxified and sanitized view of the page, visit original site.