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

Yoga fails to compile #450

Closed
SimonSapin opened this issue Apr 19, 2023 · 4 comments · Fixed by #451
Closed

Yoga fails to compile #450

SimonSapin opened this issue Apr 19, 2023 · 4 comments · Fixed by #451
Labels
bug Something isn't working

Comments

@SimonSapin
Copy link
Contributor

taffy version

fda1f88, current main

Platform

Archlinux

What you did

Run cargo test. Yoga fails to compile.

Alternatives

I’d be nice if either:

  • The Taffy project provides some reproducible way to make an environment (container or whatever) that has everything needed to run tests. (CONTRIBUTING.md suggests that chromedriver can also be tricky)
  • There is a way to run a subset of tests that does need Yoga

What went wrong

Output line that seems most relevant:

  src/yoga/yoga/Yoga.h:371:10: fatal error: 'functional' file not found

Full output:

   Compiling yoga v0.4.0
error: failed to run custom build command for `yoga v0.4.0`

Caused by:
  process didn't exit successfully: `/home/simon/projects/taffy/target/debug/build/yoga-96bccafd4f3c4b8f/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=src/yoga/yoga
  TARGET = Some("x86_64-unknown-linux-gnu")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CXX_x86_64-unknown-linux-gnu
  CXX_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CXX_x86_64_unknown_linux_gnu
  CXX_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CXX
  HOST_CXX = None
  cargo:rerun-if-env-changed=CXX
  CXX = None
  cargo:rerun-if-env-changed=CXXFLAGS_x86_64-unknown-linux-gnu
  CXXFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CXXFLAGS_x86_64_unknown_linux_gnu
  CXXFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CXXFLAGS
  HOST_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "src/yoga" "-Wall" "-Wextra" "-std=c++11" "-fno-omit-frame-pointer" "-fexceptions" "-Wall" "-O3" "-fPIC" "-o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/event/event.o" "-c" "src/yoga/yoga/event/event.cpp"
  exit status: 0
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "src/yoga" "-Wall" "-Wextra" "-std=c++11" "-fno-omit-frame-pointer" "-fexceptions" "-Wall" "-O3" "-fPIC" "-o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/internal/experiments.o" "-c" "src/yoga/yoga/internal/experiments.cpp"
  exit status: 0
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "src/yoga" "-Wall" "-Wextra" "-std=c++11" "-fno-omit-frame-pointer" "-fexceptions" "-Wall" "-O3" "-fPIC" "-o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/log.o" "-c" "src/yoga/yoga/log.cpp"
  exit status: 0
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "src/yoga" "-Wall" "-Wextra" "-std=c++11" "-fno-omit-frame-pointer" "-fexceptions" "-Wall" "-O3" "-fPIC" "-o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/Utils.o" "-c" "src/yoga/yoga/Utils.cpp"
  exit status: 0
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "src/yoga" "-Wall" "-Wextra" "-std=c++11" "-fno-omit-frame-pointer" "-fexceptions" "-Wall" "-O3" "-fPIC" "-o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/YGConfig.o" "-c" "src/yoga/yoga/YGConfig.cpp"
  exit status: 0
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "src/yoga" "-Wall" "-Wextra" "-std=c++11" "-fno-omit-frame-pointer" "-fexceptions" "-Wall" "-O3" "-fPIC" "-o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/YGEnums.o" "-c" "src/yoga/yoga/YGEnums.cpp"
  exit status: 0
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "src/yoga" "-Wall" "-Wextra" "-std=c++11" "-fno-omit-frame-pointer" "-fexceptions" "-Wall" "-O3" "-fPIC" "-o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/YGLayout.o" "-c" "src/yoga/yoga/YGLayout.cpp"
  exit status: 0
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "src/yoga" "-Wall" "-Wextra" "-std=c++11" "-fno-omit-frame-pointer" "-fexceptions" "-Wall" "-O3" "-fPIC" "-o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/YGNode.o" "-c" "src/yoga/yoga/YGNode.cpp"
  exit status: 0
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "src/yoga" "-Wall" "-Wextra" "-std=c++11" "-fno-omit-frame-pointer" "-fexceptions" "-Wall" "-O3" "-fPIC" "-o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/YGNodePrint.o" "-c" "src/yoga/yoga/YGNodePrint.cpp"
  exit status: 0
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "src/yoga" "-Wall" "-Wextra" "-std=c++11" "-fno-omit-frame-pointer" "-fexceptions" "-Wall" "-O3" "-fPIC" "-o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/YGStyle.o" "-c" "src/yoga/yoga/YGStyle.cpp"
  exit status: 0
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "src/yoga" "-Wall" "-Wextra" "-std=c++11" "-fno-omit-frame-pointer" "-fexceptions" "-Wall" "-O3" "-fPIC" "-o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/YGValue.o" "-c" "src/yoga/yoga/YGValue.cpp"
  exit status: 0
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "src/yoga" "-Wall" "-Wextra" "-std=c++11" "-fno-omit-frame-pointer" "-fexceptions" "-Wall" "-O3" "-fPIC" "-o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/Yoga.o" "-c" "src/yoga/yoga/Yoga.cpp"
  exit status: 0
  cargo:rerun-if-env-changed=AR_x86_64-unknown-linux-gnu
  AR_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=AR_x86_64_unknown_linux_gnu
  AR_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_AR
  HOST_AR = None
  cargo:rerun-if-env-changed=AR
  AR = None
  cargo:rerun-if-env-changed=ARFLAGS_x86_64-unknown-linux-gnu
  ARFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=ARFLAGS_x86_64_unknown_linux_gnu
  ARFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_ARFLAGS
  HOST_ARFLAGS = None
  cargo:rerun-if-env-changed=ARFLAGS
  ARFLAGS = None
  running: ZERO_AR_DATE="1" "ar" "cq" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/libyoga.a" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/event/event.o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/internal/experiments.o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/log.o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/Utils.o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/YGConfig.o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/YGEnums.o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/YGLayout.o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/YGNode.o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/YGNodePrint.o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/YGStyle.o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/YGValue.o" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/src/yoga/yoga/Yoga.o"
  exit status: 0
  running: "ar" "s" "/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out/libyoga.a"
  exit status: 0
  cargo:rustc-link-lib=static=yoga
  cargo:rustc-link-search=native=/home/simon/projects/taffy/target/debug/build/yoga-261b21c272a3ad54/out
  cargo:rerun-if-env-changed=CXXSTDLIB_x86_64-unknown-linux-gnu
  CXXSTDLIB_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CXXSTDLIB_x86_64_unknown_linux_gnu
  CXXSTDLIB_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CXXSTDLIB
  HOST_CXXSTDLIB = None
  cargo:rerun-if-env-changed=CXXSTDLIB
  CXXSTDLIB = None
  cargo:rustc-link-lib=stdc++

  --- stderr
  fatal: not a git repository (or any of the parent directories): .git
  fatal: not a git repository (or any of the parent directories): .git
  src/yoga/yoga/Yoga.h:371:10: fatal error: 'functional' file not found
  thread 'main' panicked at 'Unable to generate bindings: ClangDiagnostic("src/yoga/yoga/Yoga.h:371:10: fatal error: 'functional' file not found\n")', /home/simon/tmp/cargo-home/registry/src/github.com-1ecc6299db9ec823/yoga-0.4.0/build.rs:65:10
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Additional information

$ tail -n 13 /home/simon/tmp/cargo-home/registry/src/github.com-1ecc6299db9ec823/yoga-0.4.0/src/yoga/yoga/Yoga.h
$ find /usr/include -name functional*
$ gcc --version
$ clang --version
$ pacman -Qo $(which c++)
#ifdef __cplusplus

#include <functional>
#include <vector>

// Calls f on each node in the tree including the given node argument.
void YGTraversePreOrder(
    YGNodeRef node,
    std::function<void(YGNodeRef node)>&& f);

void YGNodeSetChildren(YGNodeRef owner, const std::vector<YGNodeRef>& children);

#endif
/usr/include/c++/12.2.1/ext/functional
/usr/include/c++/12.2.1/functional
/usr/include/c++/12.2.1/bits/functional_hash.h
/usr/include/c++/12.2.1/tr1/functional_hash.h
/usr/include/c++/12.2.1/tr1/functional
/usr/include/c++/12.2.1/experimental/functional
/usr/include/absl/functional
clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
gcc (GCC) 12.2.1 20230201
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
/usr/bin/c++ is owned by gcc 12.2.1-2

Neither https://github.com/facebook/yoga#building or https://github.com/bschwind/yoga-rs#build list specific build-dependencies I might be missing.

@SimonSapin SimonSapin added the bug Something isn't working label Apr 19, 2023
@SimonSapin
Copy link
Contributor Author

SimonSapin commented Apr 19, 2023

cargo test succeeds (not only to compile, but tests seem to pass) if I just comment out the yoga (dev-)dependency in Taffy’s Cargo.toml. I see there’s a yoga_benchmark feature flag and guess the dependency is only used when that’s enabled, but unfortunately the obvious fix is not supported by Cargo:

error: failed to parse manifest at `/home/simon/projects/taffy/Cargo.toml`

Caused by:
  dev-dependencies are not allowed to be optional: `yoga`

@nicoburns
Copy link
Collaborator

Ah, this has been on my todo list to fix for a couple of days. Plan is to make the benchmarks (which are the only thing using yoga) their own crate. Which should also allow us to feature flag the yoga dependency properly.

FWIW, I believe it's libclang-dev that you need. yoga-rs is compiling with clang's c++ stdlib because bindgen generates Rust code that doesn't compile with recent versions of rustc from gcc's stdlib.

@SimonSapin
Copy link
Contributor Author

yoga-rs is compiling with clang's c++ stdlib

That was a good hint, thanks! The /usr/include/c++/12.2.1/functional I had is owned by the gcc package. Installing the libc++ package brought /usr/include/c++/v1/functional and fixed it for me. (I assume libc++-dev would be the package name on distro that splits -dev packages.)

@SimonSapin
Copy link
Contributor Author

Closing for bschwind/yoga-rs#57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants