tectonic-typesetting / tectonic

A modernized, complete, self-contained TeX/LaTeX engine, powered by XeTeX and TeXLive.
https://tectonic-typesetting.github.io/
Other
3.99k stars 162 forks source link

Can build standalone but not as dependency #1178

Closed sjml closed 3 months ago

sjml commented 7 months ago

I'm trying to embed Tectonic in another program but am running into build issues that I can't quite pin down...

I'm building on macOS with dependencies installed via Homebrew.

This works just fine:

git clone https://github.com/tectonic-typesetting/tectonic
cd tectonic
git submodule update --init
PKG_CONFIG_PATH=$(brew --prefix icu4c)/lib/pkgconfig cargo build

But this fails:

cargo new tectonic-embed
cd tectonic-embed
cargo add tectonic
PKG_CONFIG_PATH=$(brew --prefix icu4c)/lib/pkgconfig cargo build

With trouble building the vendored HarfBuzz, it looks like.

[snip]
error: failed to run custom build command for `tectonic_bridge_harfbuzz v0.2.9`

Caused by:
  process didn't exit successfully: `/Users/shane/Projects/tectonic-embed/target/debug/build/tectonic_bridge_harfbuzz-e78f2c9e3f07e8a3/build-script-build` (exit status: 101)
  --- stdout
  TARGET = Some("aarch64-apple-darwin")
  OPT_LEVEL = Some("0")
  HOST = Some("aarch64-apple-darwin")
  cargo:rerun-if-env-changed=CXX_aarch64-apple-darwin
  CXX_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CXX_aarch64_apple_darwin
  CXX_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CXX
  HOST_CXX = None
  cargo:rerun-if-env-changed=CXX
  CXX = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-apple-darwin
  CXXFLAGS_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_apple_darwin
  CXXFLAGS_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CXXFLAGS
  HOST_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  cargo:rerun-if-env-changed=AR_aarch64-apple-darwin
  AR_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=AR_aarch64_apple_darwin
  AR_aarch64_apple_darwin = 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_aarch64-apple-darwin
  ARFLAGS_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=ARFLAGS_aarch64_apple_darwin
  ARFLAGS_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_ARFLAGS
  HOST_ARFLAGS = None
  cargo:rerun-if-env-changed=ARFLAGS
  ARFLAGS = None
  cargo:rustc-link-lib=static=harfbuzz
  cargo:rustc-link-search=native=/Users/shane/Projects/tectonic-embed/target/debug/build/tectonic_bridge_harfbuzz-d62862240405c468/out
  cargo:rerun-if-env-changed=CXXSTDLIB_aarch64-apple-darwin
  CXXSTDLIB_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CXXSTDLIB_aarch64_apple_darwin
  CXXSTDLIB_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CXXSTDLIB
  HOST_CXXSTDLIB = None
  cargo:rerun-if-env-changed=CXXSTDLIB
  CXXSTDLIB = None
  cargo:rustc-link-lib=c++
  cargo:include-path=/Users/shane/Projects/tectonic-embed/target/debug/build/tectonic_bridge_harfbuzz-d62862240405c468/out;/opt/homebrew/Cellar/graphite2/1.3.14/include

  --- stderr
  thread 'main' panicked at /Users/shane/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tectonic_bridge_harfbuzz-0.2.9/build.rs:143:47:
  failed to copy header: Os { code: 2, kind: NotFound, message: "No such file or directory" }
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I noted this discussion where the problem was resolved by enabling external-harfbuzz but that just seems to have a different set of build issues where it looks like the XeTeX build is looking for <harfbuzz/hb.h> but the pkg-config include flag is already pointing to the harfbuzz directory so it's missing the header:

[snip]
The following warnings were emitted during compilation:

warning: tectonic_xetex_layout@0.2.4: In file included from layout/xetex-XeTeXFontInst.cpp:42:
warning: tectonic_xetex_layout@0.2.4: layout/tectonic_xetex_layout.h:42:10: fatal error: 'harfbuzz/hb.h' file not found
warning: tectonic_xetex_layout@0.2.4: #include <harfbuzz/hb.h>
warning: tectonic_xetex_layout@0.2.4:          ^~~~~~~~~~~~~~~
warning: tectonic_xetex_layout@0.2.4: 1 error generated.

error: failed to run custom build command for `tectonic_xetex_layout v0.2.4`

I was about to start mucking around with CFLAGS but figured there might be some deeper issue I'm missing, at least with regard to getting the vendored version building properly when the Tectonic is a dependency.

mtybadger commented 1 month ago

I have this too, it's definitely not completed with the C++17 upgrade

mtybadger commented 1 month ago

Found it - it's actually already been fixed in d5a605d, but for some reason that doesn't land if you download tectonic from master and run git submodule update --init --recursive. That change fixed it for me, if anyone else has this problem!

Prashant4900 commented 3 weeks ago

git submodule update --init --recursive

where you run this command or i still facing same issue even after update the field