Giter VIP home page Giter VIP logo

Comments (8)

danakj avatar danakj commented on June 16, 2024 1

A followup blog post was made about this issue specifically: https://nibblestew.blogspot.com/2023/12/even-more-breakage-in-c-module-world.html

from subspace.

danakj avatar danakj commented on June 16, 2024

Same error occurs in clang 17, seems to be something else. Maybe a cmake change?

from subspace.

danakj avatar danakj commented on June 16, 2024

Yeah it's CMake 3.28 which added C++20 module support. CMake's ninja generator puts something like this into the command line for each file:

@third_party\\googletest\\googlemock\\CMakeFiles\\gmock_main.dir\\src\\gmock-all.cc.obj.modmap

And libclang doesn't seem to know what to do with it.

from subspace.

danakj avatar danakj commented on June 16, 2024

No clang docs seem to mention what the @ means either :(

from subspace.

danakj avatar danakj commented on June 16, 2024

it's from here: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8611/diffs

Which adds the @foo.modmap to the command line, which CL docs say is a command-file which has other commands in it? https://learn.microsoft.com/en-us/cpp/build/reference/cl-command-files?view=msvc-170

But the files don't exist for me after building actual binaries either.

The test expects @foo.modmap or -fmodule-mapper=foo.modmap and GCC docs mention the latter: https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Module-Mapper.html

from subspace.

danakj avatar danakj commented on June 16, 2024

Oh this blog post discusses it: https://nibblestew.blogspot.com/2023/10/the-road-to-hell-is-paved-with-good.html

Ninja does not support dynamic compiler argument generation. Which is good, because it makes things faster, simpler and more reliable. This does not stop CMake, which hacked it on top anyway. The compiler command they invoke looks like the following.

clang++ <some compiler flags> @path/to/somefile.modmap <more flags>
The @file syntax means "read the contents of the file and pretend that it contains command line arguments". The file itself is created at build time with a scanner program. Here's what its contents look like.

-x c++-module
-fmodule-output=CMakeFiles/modtest.dir/M0.pcm
-fmodule-file=M1=CMakeFiles/modtest.dir/M1.pcm
-fmodule-file=M2=CMakeFiles/modtest.dir/M2.pcm
-fmodule-file=M3=CMakeFiles/modtest.dir/M3.pcm
-fmodule-file=M4=CMakeFiles/modtest.dir/M4.pcm
-fmodule-file=M5=CMakeFiles/modtest.dir/M5.pcm
-fmodule-file=M6=CMakeFiles/modtest.dir/M6.pcm
-fmodule-file=M7=CMakeFiles/modtest.dir/M7.pcm
-fmodule-file=M8=CMakeFiles/modtest.dir/M8.pcm
-fmodule-file=M9=CMakeFiles/modtest.dir/M9.pcm

This is a file that cmake generates before running the compile command. Since clang tools are not cmake... the file does not exist and the resulting compile_commands.json is broken for any other use. Oh no.

from subspace.

danakj avatar danakj commented on June 16, 2024

Since only CMake will generate these files during compilation, we can't use them obviously. I think our only option is to strip them out of the command line. This will work until code actually uses modules at which point CMake will not provide a command line in compile_commands.json that is suitable to reproduce building the C++ file. And we may need to get off of CMake or something.

from subspace.

danakj avatar danakj commented on June 16, 2024

Posted to the cmake discussion here: https://discourse.cmake.org/t/how-to-control-the-location-of-the-c-20-binary-module-interface-bmi-output-directory/7968/13

For now, we will strip out the modmap command-file from the command-line that CMake generates specifically by looking for @.*\.modmap.

from subspace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.