Skip to content
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

C++ Module: zig c++ does not support #1

Open
kassane opened this issue Apr 22, 2023 · 2 comments
Open

C++ Module: zig c++ does not support #1

kassane opened this issue Apr 22, 2023 · 2 comments

Comments

@kassane
Copy link
Owner

kassane commented Apr 22, 2023

Zig toolchain for C & C++ projects is based on presenting pure LLVM build tools (clang/++ + lld + libcxx).
Previously tried some tests of C++ module using zig in addition to switching C++ ABI (LLVM to GNU).

See: https://github.com/kassane/fmt/actions/runs/4773408799

cc: @vitaut @DanielaE

References:

@DanielaE
Copy link

Correct. Clang doesn't recognize .cc as a valid extension for module TUs and requires help by -x c++-module.

My collective knowledge about modules and {fmt} can be found here on my module testing branch

@kassane
Copy link
Owner Author

kassane commented Apr 28, 2023

Nice!

My test on your testing-branch:

$> zig build -DTests

zig build-exe module-test Debug native: error: error(compilation): clang failed with stderr: /home/kassane/fmt_modules/test/module-test.cc:47:8: fatal error: module 'fmt' not found

zig build-exe module-test Debug native: error: the following command failed with 1 compilation errors:
/home/kassane/zig/0.11.0-dev.2868+1a455b2dd/files/zig build-exe -cflags -std=c++2b -- /home/kassane/fmt_modules/test/module-test.cc -cflags -Wall -Wextra -Wno-deprecated-declarations -- /home/kassane/fmt_modules/test/gtest/gmock-gtest-all.cc /home/kassane/fmt_modules/test/gtest-extra.cc /home/kassane/fmt_modules/test/enforce-checks-test.cc /home/kassane/fmt_modules/test/util.cc /home/kassane/fmt_modules/zig-cache/o/16ac77627b4f5a43a413bfb9de2c9425/libfmt.a -lc++ --cache-dir /home/kassane/fmt_modules/zig-cache --global-cache-dir /home/kassane/.cache/zig --name module-test -I /home/kassane/fmt_modules/include -I /home/kassane/fmt_modules/test -I /home/kassane/fmt_modules/test/gtest -I /home/kassane/fmt_modules/zig-out/include -D _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 -D GTEST_HAS_PTHREAD=0 --listen=-
Build Summary: 39/42 steps succeeded; 1 failed (disable with -fno-summary)
install transitive failure
├─ install include/ cached
├─ install fmt cached
│  └─ zig build-lib fmt Debug native cached 8ms MaxRSS:34M
├─ install args-test cached
│  └─ zig build-exe args-test Debug native cached 10ms MaxRSS:34M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install core-test cached
│  └─ zig build-exe core-test Debug native cached 1s MaxRSS:32M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install unicode-test cached
│  └─ zig build-exe unicode-test Debug native cached 11ms MaxRSS:33M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install assert-test cached
│  └─ zig build-exe assert-test Debug native cached 11ms MaxRSS:33M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install std-test cached
│  └─ zig build-exe std-test Debug native cached 12ms MaxRSS:34M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install xchar-test cached
│  └─ zig build-exe xchar-test Debug native cached 11ms MaxRSS:33M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install ostream-test cached
│  └─ zig build-exe ostream-test Debug native cached 13ms MaxRSS:33M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install printf-test cached
│  └─ zig build-exe printf-test Debug native cached 16ms MaxRSS:34M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install scan-test cached
│  └─ zig build-exe scan-test Debug native cached 12ms MaxRSS:34M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install ranges-test cached
│  └─ zig build-exe ranges-test Debug native cached 12ms MaxRSS:34M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install color-test cached
│  └─ zig build-exe color-test Debug native cached 12ms MaxRSS:34M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install chrono-test cached
│  └─ zig build-exe chrono-test Debug native cached 13ms MaxRSS:33M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install compile-test cached
│  └─ zig build-exe compile-test Debug native cached 13ms MaxRSS:33M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install compile-fp-test cached
│  └─ zig build-exe compile-fp-test Debug native cached 12ms MaxRSS:34M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install format-test cached
│  └─ zig build-exe format-test Debug native cached 11ms MaxRSS:32M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install os-test cached
│  └─ zig build-exe os-test Debug native cached 12ms MaxRSS:34M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install noexception-test cached
│  └─ zig build-exe noexception-test Debug native cached 17ms MaxRSS:32M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
├─ install posix-mock-test cached
│  └─ zig build-exe posix-mock-test Debug native cached 1s MaxRSS:33M
│     ├─ zig build-lib fmt Debug native (reused)
│     └─ install include/ (reused)
└─ install module-test transitive failure
   └─ zig build-exe module-test Debug native 1 errors
      ├─ zig build-lib fmt Debug native (reused)
      └─ install include/ (reused)
# zig v0.11.0-dev/master is LLVM 16.0.1

$> zig cc -x c++ -std=c++2b -Iinclude test/module-test.cc -o module -lc++ -Lzig-out/lib -lfmt
test/module-test.cc:47:8: fatal error: module 'fmt' not found
import fmt;
~~~~~~~^~~
1 error generated.

$>  zig cc -x c++-module -std=c++2b -Iinclude test/module-test.cc -o module -lc++ -Lzig-out/lib -lfmt
error: language not recognized: 'c++-module'

Edit: missing --precompile, but still not resolved.

I'll fork zig toolchain to add -x c++-module.
Utilizing your branch as test base!

thank you for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants