-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
I was following instructions on: https://libc.llvm.org/full_host_build.html#id3
(with slightly modified cmake command, i.e. without Sphinx):
cmake \
-B ~/build-folder \
-S runtimes \
-G Ninja \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DLLVM_ENABLE_RUNTIMES="libc;compiler-rt" \
-DLLVM_LIBC_FULL_BUILD=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DLLVM_LIBC_INCLUDE_SCUDO=ON \
-DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON \
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF \
-DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DLIBC_CMAKE_VERBOSE_LOGGING=ON
And then:
ninja -C ~/build-folder check-libc
Which fails with:
Traceback (most recent call last):
File "~/llvm-project/libc/hdrgen/yaml_to_classes.py", line 284, in <module>
main()
File "~/llvm-project/libc/hdrgen/yaml_to_classes.py", line 261, in main
header = load_yaml_file(args.yaml_file, header_class, args.entry_points)
File "~/llvm-project/libc/hdrgen/yaml_to_classes.py", line 123, in load_yaml_file
yaml_data = yaml.safe_load(f)
AttributeError: module 'yaml' has no attribute 'safe_load'
ninja: build stopped: subcommand failed.
Near:
llvm-project/libc/hdrgen/yaml_to_classes.py
Lines 120 to 121 in 5f0db7c
with open(yaml_file, "r") as f: | |
yaml_data = yaml.safe_load(f) |
When I add the following code, just before the yaml.safe_load
,
print(dir(yaml))
print((yaml).__path__)
I get the output:
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
_NamespacePath(['~/llvm-project/libc/hdrgen/yaml'])
Which probably means, that import yaml
is trying to "import" the https://github.com/llvm/llvm-project/tree/main/libc/hdrgen/yaml directory instead of PyYaml
However, given that
Note: I do have PyYaml
installed within a conda environment which is activated, so I don't think this is an issue with my python setup:
For instance, the following works as expected:
❯ /usr/bin/env python3
Python 3.13.1 | packaged by Anaconda, Inc. | (main, Dec 11 2024, 10:35:08) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> 'safe_load' in dir(yaml)
True
Given that the CI has been passing for months, it seems that I might be missing some sort of extra setup so that /usr/bin/env python3
looks at the right path to import yaml
(which might need to be added to https://libc.llvm.org/full_host_build.html#configure-the-build-for-development)
Also looked at:
https://libc.llvm.org/dev/header_generation.html#common-errors, but this page didn't seem to mention my issue