Comments (9)
@tniessen short answer is no, cross wouldnt help with a more elegant solution, the solution would be equally applicable with or without cross. I dont think your specific example here is related to what this issue is about, but feel free to open a new issue with more information and maybe we can work something out
from cross.
Can we solve this problem in our images?
Should we add -I/usr/include
in all our BINDGEN_EXTRA_CLANG_ARGS_<target>
s maybe? One risk I see with this is that we introduce contamination, where the header files could potentially be different for the host architecture and the target architecture. How does clang prioritize the include dirs, right to left?
from cross.
BINDGEN_EXTRA_CLANG_ARGS_<target>=--sysroot=$CROSS_SYSROOT -I/usr/include -v
gives
#include <...> search starts here:
/usr/include
/usr/include/clang/10.0.0/include
$CROSS_SYSROOT/include
For C++ inputs, if there are multiple -I options, these directories are searched in the order they are given before the standard system directories are searched.
BINDGEN_EXTRA_CLANG_ARGS_<target>=--sysroot=$CROSS_SYSROOT -nostdinc -I$CROSS_SYSROOT/include -I/usr/include
works, but disables the std, there's no way to reenable it... we need -ibuiltininc
(available on clang-11 and up) I think but that also doesn't to enable the clang includes
#include <...> search starts here:
$CROSS_SYSROOT/include
/usr/include
**edit
-idirafter/usr/include
is exactly what we want
aarch64-unknown-linux-gnu example
# Cross.toml
[target.aarch64-unknown-linux-gnu.env]
passthrough = ["""BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_linux_gnu=--sysroot=/usr/aarch64-linux-gnu -idirafter/usr/include"""]
gives
#include <...> search starts here:
/usr/lib/llvm-11/lib/clang/10.0.0/include
/usr/aarch64-linux-gnu/include
/usr/include
I've updated the first post from using -I/usr/include
to be -idirafter/usr/include
from cross.
Should we add
-I/usr/include
in all ourBINDGEN_EXTRA_CLANG_ARGS_<target>
s maybe? One risk I see with this is that we introduce contamination, where the header files could potentially be different for the host architecture and the target architecture. How does clang prioritize the include dirs, right to left?
I think -idirafter/usr/include
is the way to do this, I don't see much hindering us from adding this to our images
from cross.
Some more investigating, pkg-config strips -I/usr/include
as it's a system include path, setting PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1
resolves this, I've modified the code to reflect this. I think this is wanted behaviour for the pkg_config
crate
root@8f4378f92f97:/# PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config libssl --cflags --libs
-I/usr/include -L/usr/lib/aarch64-linux-gnu -lssl
root@8f4378f92f97:/# pkg-config libssl --cflags --libs
-L/usr/lib/aarch64-linux-gnu -lssl
from cross.
Another issue, should we really use PKG_CONFIG_PATH
? From what I can gather, the expected thing to do is to use aarch64-linux-gnu-pkg-config
, which discovers the path automatically. It also curiously omits -I/usr/include
, very interesting...
from cross.
Some (if not most?)
*-dev
packages on ubuntu dist only include headers in/usr/include
, this means that theBINDGEN_EXTRA_CLANG_ARGS_<target>=--sysroot=$CROSS_SYSROOT
I'm not entirely sure of the problem this issue is about, since not all containers use the same approach. Since you mention using Ubuntu's -dev
packages, I assume you're talking about containers for targets using dpkg
's foreign-architecture support, but then it seems to be the sysroot is just /
so there should be no problem to start with. So I'm basically confused :)
from cross.
Maybe I'm the one that is confused, we set the env var in #707
I was under the impression that it was needed, but maybe it wasn't needed for every target, and only needed for android
from cross.
bindgen
can't properly find these headers if the*-sys
-crate doesn't usepkg-config
probing
@Emilgardis In my case, I'm using bindgen
with some C header files that do not belong to any pre-installed library, so as far as I know, I cannot reasonably use pkg-config
. However, with default configuration only, this results in errors such as fatal error: 'stddef.h' file not found
. (The reason is that the Rust crate needs to be aware of the memory layout of some C data structures, but it does not actually link against any C library.)
This works just fine with the default toolchain/target, but cross-compiling without cross
requires manual modifications of the include path. Is there a more elegant solution now that I'm trying to use cross
?
from cross.
Related Issues (20)
- cross build --target x86_64-pc-windows-gnu missing synchronization library HOT 5
- CARGO_TARGET_AARCH64_LINUX_ANDROID_RUSTFLAGS Parse error when there are spaces in the parameters HOT 4
- failed to run custom build command for `openssl-sys v0.9.101` HOT 1
- Could we add gfortran support to our images? HOT 3
- Unable to cross compile for Windows (cannot find -lsynchronization) HOT 2
- Upgrade qemu and integrate `qemu-user` runners for `loongarch64-linux-gnu`
- Missing manifest file issue HOT 5
- Unable to compile project HOT 4
- Ability to override base image? HOT 5
- Give $CROSS_WORKDIR in pre-build
- Publish a new release HOT 2
- Unable to use cross build --offline in docker-in-docker environment HOT 4
- zig build error: UnknownOperatingSystem, on aarch64 opencv-rs version 0.91.2 HOT 2
- zig build undefined symbols on ld linking HOT 3
- Cross does not have an ARM64 platform docker image for v0.2.5 and main HOT 2
- target armv7 on macOS Silicon fails: linker x86_64-unknown-linux-gnu-gcc unknown HOT 7
- Are ghcr.io/cross-rs/... Docker images still being updated (last update 2022)? HOT 3
- Nightly builds fail on many platforms now that nightly sets `-fuse-ld=lld` HOT 3
- git2::Repository::open error: repository path is not owned by current user HOT 3
- ```CROSS_CONTAINER_OPTS``` does not replace ```--platform linux/amd64``` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cross.