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

experimental/meta file not found #105

Open
bshafi opened this issue Oct 19, 2024 · 4 comments
Open

experimental/meta file not found #105

bshafi opened this issue Oct 19, 2024 · 4 comments

Comments

@bshafi
Copy link

bshafi commented Oct 19, 2024

Describe the bug
I'm attempting to build this compiler to try out the C++26 reflection however I can't seem to get any examples to compile.
The issue each time is that fatal error: 'experimental/meta' file not found. I'm not sure what compile option I need to add so that it compiles.

I have searched for the meta header file with find | grep "meta" in the folder where I built clang and it returns no results which makes me think that there may be an option in the build steps that I have not enabled that keeps experimental/meta from being added to the final build.

I have confirmed that experimental/meta is in the repository.

To Reproduce
Building clang

mkdir build
cd build
cmake -G "Visual Studio 17" -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Release ..\llvm
cmake --build .

Compile the code

clang.exe -freflection -std=c++26 -fexpansion-statements .\main.cpp -o main.exe

Result:

.\main.cpp:1:10: fatal error: 'experimental/meta' file not found
    1 | #include <experimental/meta>
      |          ^~~~~~~~~~~~~~~~~~~
1 error generated.

Code that I'm trying to compile: main.cpp

#include <experimental/meta>

#include <iostream>
#include <string>

template <typename E>
  constexpr std::string enum_to_string(E value) {
	    template for (constexpr auto e : std::meta::members_of(^E)) {
		        if (value == [:e:]) {
				      return std::string(std::meta::name_of(e));
				          }
			  }

	      return "<unnamed>";
  }

enum Color { red, green, blue };

int main() {
	std::cout << enum_to_string(Color::red) << std::endl;
}

Expected behavior
The code should build and when I run it, it should print red.

Environment (please complete the following information):
Windows 10
Visual Studio 17

I've tried almost all variants of these instructions. I've compiled the code with clang.exe -freflection -std=c++26 -fexpansion-statements -fparameter-reflection -fexpansion-statements -fconsteval-blocks -freflection-new-syntax -freflection-latest .\main.cpp -o main.exe. I've removed the #include <experimental/meta> and tried to compile it.

@Yaraslaut
Copy link

Yaraslaut commented Oct 20, 2024

You need to build clang and libc++, you can check out this docker file https://github.com/simdjson/experimental_json_builder/blob/main/Dockerfile

And then change standard library that compiler uses to libc++, instead of libstdc++ on linux and whatever is on windows
Here is a compiler option that you set via cmake

target_compile_options($project_name INTERFACE  -freflection -stdlib=libc++ -std=c++26)

@bshafi
Copy link
Author

bshafi commented Oct 21, 2024

Thanks for the reply! I am currently stuck trying to get libc++ on windows. I get an error unused argument -stdlib=libc++. I have tried different methods to get it to compile with clang and they don't work. I'm going to close this issue for now. If any windows user wants to document how they got libc++ to compile and work this issue can be reopened.

@bshafi bshafi closed this as completed Oct 21, 2024
@YiRanMushroom
Copy link

Hello, I just saw this issue when I was struggling to find ways to compile programs on Windows. I would like to know whether you found any ways to make this work on Windows.

I compiled clang successfully but I don't think the libc++ was compiled. I used

cmake -DLLVM_ENABLE_PROJECTS="clang" -G "Visual Studio 17 2022" -Thost=x64 ..\llvm -DLLVM_HOST_TRIPLE=x86_64 -DLLVM_RUNTIME_TARGETS=x86_64 -DLLVM_ENABLE_RUNTIMES="libc;libcxx" -DCMAKE_INSTALL_PREFIX="E:/llvm-reflect" -DLLVM_PARALLEL_COMPILE_JOBS=32 -DLLVM_PARALLEL_LINK_JOBS=32 -DLLVM_PARALLEL_TABLEGEN_JOBS=32

to generate msvc sln files and used msvc to build clang. I also ran the build_all and install task but I encountered several compilation errors, and I also don't think the libc++ files were generated successfully.

When I used clang++ to compile programs, it reported that experimental/meta file not found. I also tried to add some files in libcxx, but there are still some missing files.

If you have already found a way to make this work, could you please document the process here? And if you haven't could you consider reopening this issue so that we could probably get more support on resolving this issue? Thank you.

@bshafi
Copy link
Author

bshafi commented Nov 17, 2024

No problem.
I'm no longer actively trying to work on this issue so I won't be responding much.

@bshafi bshafi reopened this Nov 17, 2024
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

3 participants