fails to build on debian sid
Hi,
Building ada-url on debian sid fails.
Running the following commands:
```sh
git clone --depth=1 https://github.com/ada-url/rust.git ada-url
cd ada-url
cargo build
```
<details>
<summary>Produces the following output:</summary>
```
Compiling ada-url v2.2.1 (/ada-url)
The following warnings were emitted during compilation:
warning: ada-url@2.2.1: In file included from ./deps/ada.cpp:3:
warning: ada-url@2.2.1: ./deps/ada.h:20:10: fatal error: 'string' file not found
warning: ada-url@2.2.1: #include <string>
warning: ada-url@2.2.1: ^~~~~~~~
warning: ada-url@2.2.1: 1 error generated.
error: failed to run custom build command for `ada-url v2.2.1 (/ada-url)`
Caused by:
process didn't exit successfully: `/ada-url/target/debug/build/ada-url-ba3156cf87bc7d44/build-script-build` (exit status: 1)
--- stdout
OPT_LEVEL = Some("0")
TARGET = Some("x86_64-unknown-linux-gnu")
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 = Some("clang++")
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
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
running: "clang++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=x86_64-unknown-linux-gnu" "-std=c++17" "-I" "./deps/ada.h" "-I" "./deps/ada_c.h" "-Wall" "-Wextra" "-o" "/ada-url/target/debug/build/ada-url-b4939785ec9bcc43/out/./deps/ada.o" "-c" "./deps/ada.cpp"
cargo:warning=In file included from ./deps/ada.cpp:3:
cargo:warning=./deps/ada.h:20:10: fatal error: 'string' file not found
cargo:warning=#include <string>
cargo:warning= ^~~~~~~~
cargo:warning=1 error generated.
exit status: 1
--- stderr
error occurred: Command "clang++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=x86_64-unknown-linux-gnu" "-std=c++17" "-I" "./deps/ada.h" "-I" "./deps/ada_c.h" "-Wall" "-Wextra" "-o" "/ada-url/target/debug/build/ada-url-b4939785ec9bcc43/out/./deps/ada.o" "-c" "./deps/ada.cpp"with args "clang++" did not execute successfully (status code exit status: 1).
```
</details>
It seems that clang cannot find the c++ stdlib... 🤔
Moreover, the build script [unconditionally sets](https://github.com/ada-url/rust/blob/720fa45da6718e483465b7da954a77cff1424d06/build.rs#L178) the compiler to `clang++`, which makes trying another compiler (or another clang version) impossible.
If I comment out the [aforementioned line](https://github.com/ada-url/rust/blob/720fa45da6718e483465b7da954a77cff1424d06/build.rs#L179) and build with `CXX=g++ cargo build`, the library builds correctly and tests pass:
```sh
$ CXX=g++ cargo build
Compiling ada-url v2.2.1 (/ada-url)
warning: ada-url@2.2.1: cc1plus: warning: ./deps/ada.h: not a directory
warning: ada-url@2.2.1: cc1plus: warning: ./deps/ada_c.h: not a directory
Finished dev [unoptimized + debuginfo] target(s) in 3.57s
```
Also note the warnings caused by the build script's passing files to [`cc::Build::include()`](https://docs.rs/cc/latest/cc/struct.Build.html#method.include) instead of directories.
IMO, the build script should let the `cc` crate detect the correct compiler on UNIX platforms.
关闭于 2024-02-02 3 条评论