Skip to content

Commit

Permalink
clang-cl import std
Browse files Browse the repository at this point in the history
Clang 19 allows to export redeclarations within language linkage.
llvm/llvm-project#98583

Exporting implicitly declared `type_info`/`operator new`/`operator delete` is no longer illegal.
llvm/llvm-project#90620

Clang 19.1.1 with VS 17.11 supports `import std`.
- llvm/llvm-project#108732
- microsoft/STL#4626
  • Loading branch information
huangqinjin committed Nov 11, 2024
1 parent 323e301 commit b26b766
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ jobs:
run: cmake -P workflow.cmake -- clang

- name: clang-win32
run: make clang-win32 CXXFLAGS="-Xmicrosoft-windows-sys-root /opt/msvc -fuse-ld=lld -target x86_64-pc-windows-msvc" LAUNCHER="WINEDEBUG=-all wine "
run: make clang-win32 VCTOOLSINSTALLDIR=/opt/msvc CXXFLAGS="-Xmicrosoft-windows-sys-root /opt/msvc -fuse-ld=lld -target x86_64-pc-windows-msvc" LAUNCHER="WINEDEBUG=-all wine "

- name: cmake x-clang-win32
run: cmake -P workflow.cmake -- x-clang-win32

- name: clang-cl
run: make clang-cl CXXFLAGS="-winsysroot /opt/msvc -fuse-ld=lld" LAUNCHER="WINEDEBUG=-all wine "
run: make clang-cl VCTOOLSINSTALLDIR=/opt/msvc CXXFLAGS="-winsysroot /opt/msvc -fuse-ld=lld" LAUNCHER="WINEDEBUG=-all wine "

- name: gcc snapshot
continue-on-error: true
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
run: |
export PATH=/opt/compiler-explorer/clang-trunk/bin:$PATH
export LD_LIBRARY_PATH=$(dirname $(clang -print-file-name=libc++.so)):$LD_LIBRARY_PATH
make clang-win32 CXXFLAGS="-Xmicrosoft-windows-sys-root /opt/msvc -fuse-ld=lld -target x86_64-pc-windows-msvc" LAUNCHER="WINEDEBUG=-all wine "
make clang-win32 VCTOOLSINSTALLDIR=/opt/msvc CXXFLAGS="-Xmicrosoft-windows-sys-root /opt/msvc -fuse-ld=lld -target x86_64-pc-windows-msvc" LAUNCHER="WINEDEBUG=-all wine "
- name: cmake x-clang-win32 trunk
continue-on-error: true
Expand All @@ -110,7 +110,7 @@ jobs:
run: |
export PATH=/opt/compiler-explorer/clang-trunk/bin:$PATH
export LD_LIBRARY_PATH=$(dirname $(clang -print-file-name=libc++.so)):$LD_LIBRARY_PATH
make clang-cl CXXFLAGS="-winsysroot /opt/msvc -fuse-ld=lld" LAUNCHER="WINEDEBUG=-all wine "
make clang-cl VCTOOLSINSTALLDIR=/opt/msvc CXXFLAGS="-winsysroot /opt/msvc -fuse-ld=lld" LAUNCHER="WINEDEBUG=-all wine "
- name: msvc-wine
run: PATH=/opt/msvc/bin/x64:$PATH make msvc LAUNCHER="WINEDEBUG=-all wine " VCTOOLSINSTALLDIR=/opt/msvc
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ clang-cl: \
module-partition/clang-cl \
module-impl/clang-cl \
header-unit/clang-cl \
import-std/clang-cl \
shared-lib/clang-cl \

clang-win32: \
named-module/clang \
module-partition/clang \
module-impl/clang \
header-unit/clang \
import-std/clang-win32 \
shared-lib/clang-win32 \

clang-mingw: \
Expand Down Expand Up @@ -55,6 +57,8 @@ TARGETS1 = \
header-unit/gcc \
import-std/msvc \
import-std/clang \
import-std/clang-win32 \
import-std/clang-cl \
shared-lib/msvc \
shared-lib/clang \
shared-lib/clang-win32 \
Expand Down
11 changes: 11 additions & 0 deletions import-std/Makefile.clang-cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
hello.exe: main.cpp std.obj std.pcm
clang-cl /EHsc /std:c++latest -fprebuilt-module-path=. -D__cpp_lib_modules=202207L main.cpp std.obj /Fe:hello $(CXXFLAGS)

std.obj std.pcm:
clang-cl /EHsc /std:c++latest -Wno-reserved-module-identifier -Wno-include-angled-in-module-purview \
-fprebuilt-module-path=. -fmodule-output=std.pcm \
-c -x c++-module $(CXXFLAGS) -- "$(VCTOOLSINSTALLDIR)/modules/std.ixx"

clean:
-del *.pcm *.obj *.exe
-rm *.pcm *.obj *.exe
11 changes: 11 additions & 0 deletions import-std/Makefile.clang-win32
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
hello.exe: main.cpp std.o std.pcm
clang++ -std=c++23 -fprebuilt-module-path=. -D__cpp_lib_modules=202207L main.cpp std.o -o hello.exe $(CXXFLAGS)

std.o std.pcm:
clang++ -std=c++23 -Wno-reserved-module-identifier -Wno-include-angled-in-module-purview \
-fprebuilt-module-path=. -fmodule-output=std.pcm \
-c -x c++-module "$(VCTOOLSINSTALLDIR)/modules/std.ixx" $(CXXFLAGS)

clean:
-del *.pcm *.o *.exe
-rm *.pcm *.o *.exe

0 comments on commit b26b766

Please sign in to comment.