llvmenv icon indicating copy to clipboard operation
llvmenv copied to clipboard

fatal error: mach-o/compact_unwind_encoding.h: No such file or directory

Open eggplants opened this issue 3 years ago • 18 comments

See: https://gist.github.com/eggplants/d590f1cb5d2d0ca19aa87e6ed83089f7 This log is the result of trying to run below code on GitHub Actions:

cargo install --git https://github.com/llvmenv/llvmenv -q
llvmenv init
llvmenv build-entry 12.0.0

But it was terminated because an error occurred:

...
2021-09-13T16:04:00.3544688Z [ 79%] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/UnwindInfoSection.cpp.o
2021-09-13T16:04:00.4650714Z In file included from /home/runner/.cache/llvmenv/12.0.0/tools/lld/MachO/UnwindInfoSection.cpp:9:
2021-09-13T16:04:00.4653439Z /home/runner/.cache/llvmenv/12.0.0/tools/lld/MachO/UnwindInfoSection.h:15:10: fatal error: mach-o/compact_unwind_encoding.h: No such file or directory
2021-09-13T16:04:00.4655035Z    15 | #include "mach-o/compact_unwind_encoding.h"
2021-09-13T16:04:00.4655865Z       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-09-13T16:04:00.4656632Z compilation terminated.
2021-09-13T16:04:00.4673305Z make[2]: *** [tools/lld/MachO/CMakeFiles/lldMachO2.dir/build.make:90: tools/lld/MachO/CMakeFiles/lldMachO2.dir/UnwindInfoSection.cpp.o] Error 1
2021-09-13T16:04:00.4675085Z make[1]: *** [CMakeFiles/Makefile2:96891: tools/lld/MachO/CMakeFiles/lldMachO2.dir/all] Error 2
2021-09-13T16:04:00.4683395Z make: *** [Makefile:156: all] Error 2
2021-09-13T16:04:00.4705078Z thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: CommandError { errno: 2, cmd: "\"cmake\" \"--build\" \"/home/runner/.cache/llvmenv/12.0.0/build\" \"--target\" \"install\"", stdout: None, stderr: None }', src/bin/llvmenv.rs:173:32
2021-09-13T16:04:00.4706978Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2021-09-13T16:04:00.4721146Z ##[error]Process completed with exit code 101.
2021-09-13T16:04:00.4854596Z Post job cleanup.
...

eggplants avatar Sep 13 '21 23:09 eggplants

Getting this as well on Ubuntu 21.10. See also https://groups.google.com/g/llvm-dev/c/gIY5COm6V5E.

raxod502 avatar Nov 07 '21 19:11 raxod502

Same issue on RHEL7 too

Please help us here

AbinayaSandhiyaM avatar Nov 24 '21 15:11 AbinayaSandhiyaM

Getting this issue as well. Using Fedora Workstation 35.

Tried installing v12.0.1 & v13.0.0, same issue for both. Please help!

atlx avatar Dec 09 '21 18:12 atlx

Are there any workaround for this? Got this issue while building v13.0.0 on arch linux

developomp avatar Dec 10 '21 07:12 developomp

related: https://llvm.discourse.group/t/unable-to-package-llvm-version-12-0-0-1-as-rpm-in-rhel7/4874/3

eggplants avatar Dec 12 '21 09:12 eggplants

Maybe this issue causes lack of mach-o/compact_unwind_encoding.h in libunwind

eggplants avatar Dec 12 '21 09:12 eggplants

(memo)

libunwind-12.0.0.src.tar.xz contains libunwind-12.0.0.src/include/mach-o/compact_unwind_encoding.h. However, cmake says fatal error: mach-o/compact_unwind_encoding.h: No such file or directory.

eggplants avatar Dec 12 '21 10:12 eggplants

I got these same error message when I want to do with 13.0.0 or 13.0.1-rc1.

D3vl0per avatar Jan 06 '22 01:01 D3vl0per

I solved it with this apk add llvm-libunwind-dev.

D3vl0per avatar Jan 06 '22 02:01 D3vl0per

@D3vl0per on alpine container? If so, please share your Dockerfile.

eggplants avatar Jan 11 '22 20:01 eggplants

@eggplants https://github.com/D3vl0per/zphinx-zerver-docker/blob/main/Dockerfile.essetials-builder Built images are available at these mirror:

  • r.zsibok.hu/zphinx-zerver-docker/essetials-builder:13.0.0
  • r.zsibok.hu/zphinx-zerver-docker/essetials-builder:13.0.1-rc1
  • ghcr.io/d3vl0per/zphinx-zerver-docker/essetials-builder:13.0.0
  • ghcr.io/d3vl0per/zphinx-zerver-docker/essetials-builder:13.0.1-rc1
  • d3vm/zphinx-zerver-docker:essetials-builder-13.0.1-rc1
  • d3vm/zphinx-zerver-docker:essetials-builder-13.0.0

D3vl0per avatar Jan 12 '22 00:01 D3vl0per

Oh, without llvmenv... I'll try to build with llvmenv based on your Dockerfile.

Thank you so much for your sharing!

eggplants avatar Jan 12 '22 00:01 eggplants

Any movement on this? Just ran into it - Googlin' for a solution led me here. On Ubu 21.10 and ran llvm build-entry 13.0.0.

kitplummer avatar Feb 06 '22 23:02 kitplummer

Hi @kitplummer. I tried to run llvmenv on Docker based on @D3vl0per's post, but it still didn't work.

eggplants avatar Feb 07 '22 00:02 eggplants

In addition, a segmentation fault occurs during download. (#122)

FROM rust:alpine3.14
RUN apk update \
    && apk add \
       gcc g++ automake autoconf pkgconfig \
       cmake ninja libc-dev binutils zlib-static \
       libstdc++ llvm-libunwind-dev \
       openssl-dev --no-cache \
    && cargo install llvmenv
ENTRYPOINT ["sh"]

$ docker build -t llvmenv-alpine .
...
$ docker run -it llvmenv-alpine
/ # llvmenv init && llvmenv build-entry 13.0.0
00:23:31 [INFO] Download Tar file: https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/llvm-13.0.0.src.tar.xz
Segmentation fault

eggplants avatar Feb 07 '22 00:02 eggplants

I went thru the pain off making it all both do multiarch image - native-compile & cross-compile - in alpine musl container host either running on aarch64 or x84_64 - I solved this problem by simply just making sure libunwind source is unpacked into the llvm-src-path/../libunwind where the lld looks it for

https://github.com/pinkforest/release-packager/tree/main/ops/builder/stage-01-maximalist

I still have to refactor it and make mimalist install version of it - it's big! - but in case someone is curious about cross-compile speed multi-arch image on linux/amd64 || linux/arm/v8 and how to get past the libunwind dependency error

For the cross compiling the difficulty is that one has to compile the whole set twice.. as you need clang-tblgen and lldb-tblgen that ninja install never installs and you have to manually copy them.

Ensure that you have the latest version of docker with proper buildx and buildkit

$ docker --version
Docker version 20.10.12, build e91ed57

And update binfmt/use the right builder

sudo update-binfmts --enable
sudo apt install binfmt-support
docker run --privileged --rm tonistiigi/binfmt --install all
docker run --rm --privileged linuxkit/binfmt:latest
docker buildx create --use

Then you can build - e.g. on 16 Core/32GB RAM - 2 x architectures same time push straight to the registry:

docker login
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag yourregistryuser/yourrepo:latest \
 --build-arg LLVM_PARALLEL_COMPILE_JOBS=8 --build-arg LLVM_PARALLEL_LINK_JOBS=2 .

If you don't care about multiarch and just doing native a lot of the complexity above can be much simpler but since people were looking options for libunwind here is one

pinkforest avatar Feb 19 '22 23:02 pinkforest

This is super hacky, but creating a "mach-o" folder in "llvm\tools\lld\MachO" and adding "compact_unwind_encoding.h" in it (google it) made it compile for me. No clue if that's gonna work in the end!

EDIT : It ended up working, but we dont target MacOS, so this code is probably unused for us.

-Mat

BleuBleu avatar Mar 19 '22 06:03 BleuBleu

I made this work for myself in arch by symlinking the containing folder:

llvmenv --version
llvmenv 0.3.2

# my build command that was failing:
llvmenv build-entry 13.0.0

# my hacky fix that made it work:
ln -s "$HOME/.cache/llvmenv/13.0.0/projects/libunwind/include/mach-o" \
      "$HOME/.cache/llvmenv/13.0.0/tools/lld/MachO/mach-o"

keywordsalad avatar Jul 03 '22 22:07 keywordsalad