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

crossbuild on mac arm host with zigbuild to target aarch64-unknown-linux-musl fail #26

Open
gen-xu opened this issue Jul 26, 2024 · 2 comments

Comments

@gen-xu
Copy link
Contributor

gen-xu commented Jul 26, 2024

Host: macos arm64
Target: aarch64-unknown-linux-musl

when using zigbuild, cargo zigbuild --target aarch64-unknown-linux-musl for project that dependes on rdkafka, so indirectly uses krb5, the build fails with following error:

that looks like it can't find #include "kcmrpc.h", while this #include is defined __APPLE__ section, which should be off when compiling target is linux-musl

Is this an issue in krb5 build/configure ?

  configure: WARNING: OpenSSL not found!
  configure: WARNING: Some functions that are needed for library thread
  configure: WARNING: safety appear to be missing.
  configure: WARNING:   missing thread-safe function: gethostbyname_r
  configure: WARNING:   missing thread-safe function: getservbyname_r
  configure: WARNING: Without these functions, the installed libraries
  configure: WARNING: may not be thread-safe.
  ++ set -x
  ++ perl -p -e 'BEGIN { $SIG{__WARN__} = sub {die @_} }; $e=$ARGV; $e =~ s/OBJS\...$//; s/^/ /; s/ $//; s/ / $e/g;' OBJS.ST
  + objlist=' threads.o init-addrinfo.o plugins.o errors.o k5buf.o gmt_mktime.o fake-addrinfo.o utf8.o utf8_conv.o zap.o path.o base64.o json.o hex.o hashtab.o bcmp.o strerror_r.o dir_filenames.o secure_getenv.o'
  + ar cq libkrb5support.a threads.o init-addrinfo.o plugins.o errors.o k5buf.o gmt_mktime.o fake-addrinfo.o utf8.o utf8_conv.o zap.o path.o base64.o json.o hex.o hashtab.o bcmp.o strerror_r.o dir_filenames.o secure_getenv.o
  + rm -f ../../include/com_err.h
  + cp /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/com_err.h ../../include/com_err.h
  ++ set -x
  ++ perl -p -e 'BEGIN { $SIG{__WARN__} = sub {die @_} }; $e=$ARGV; $e =~ s/OBJS\...$//; s/^/ /; s/ $//; s/ / $e/g;' OBJS.ST
  + objlist=' error_message.o et_name.o com_err.o'
  + ar cq libcom_err.a error_message.o et_name.o com_err.o
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_h.awk outfile=et-h-prof_err.h et-h-prof_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_c.awk outfile=et-h-prof_err.c textdomain=mit-krb5 localedir= et-h-prof_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_h.awk outfile=et-c-prof_err.h et-c-prof_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_c.awk outfile=et-c-prof_err.c textdomain=mit-krb5 localedir= et-c-prof_err.et
  ++ set -x
  ++ perl -p -e 'BEGIN { $SIG{__WARN__} = sub {die @_} }; $e=$ARGV; $e =~ s/OBJS\...$//; s/^/ /; s/ $//; s/ / $e/g;' OBJS.ST
  + objlist=' prof_tree.o prof_file.o prof_parse.o prof_get.o prof_set.o prof_err.o prof_init.o'
  + ar cq libprofile.a prof_tree.o prof_file.o prof_parse.o prof_get.o prof_set.o prof_err.o prof_init.o
  ++ set -x
  ++ perl -p -e 'BEGIN { $SIG{__WARN__} = sub {die @_} }; $e=$ARGV; $e =~ s/OBJS\...$//; s/^/ /; s/ $//; s/ / $e/g;' OBJS.ST
  + objlist=' verto.o module.o verto-k5ev.o'
  + ar cq libverto.a verto.o module.o verto-k5ev.o
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_h.awk outfile=et-h-asn1_err.h et-h-asn1_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_c.awk outfile=et-h-asn1_err.c textdomain=mit-krb5 localedir= et-h-asn1_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_h.awk outfile=et-h-kdb5_err.h et-h-kdb5_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_c.awk outfile=et-h-kdb5_err.c textdomain=mit-krb5 localedir= et-h-kdb5_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_h.awk outfile=et-h-krb5_err.h et-h-krb5_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_c.awk outfile=et-h-krb5_err.c textdomain=mit-krb5 localedir= et-h-krb5_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_h.awk outfile=et-h-k5e1_err.h et-h-k5e1_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_c.awk outfile=et-h-k5e1_err.c textdomain=mit-krb5 localedir= et-h-k5e1_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_h.awk outfile=et-h-kv5m_err.h et-h-kv5m_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_c.awk outfile=et-h-kv5m_err.c textdomain=mit-krb5 localedir= et-h-kv5m_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_h.awk outfile=et-h-krb524_err.h et-h-krb524_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_c.awk outfile=et-h-krb524_err.c textdomain=mit-krb5 localedir= et-h-krb524_err.et
  ++ set -x
  ++ perl -p -e 'BEGIN { $SIG{__WARN__} = sub {die @_} }; $e=$ARGV; $e =~ s/OBJS\...$//; s/^/ /; s/ $//; s/ / $e/g;' builtin/enc_provider/OBJS.ST builtin/hash_provider/OBJS.ST builtin/md4/OBJS.ST builtin/md5/OBJS.ST builtin/sha1/OBJS.ST builtin/sha2/OBJS.ST builtin/aes/OBJS.ST builtin/des/OBJS.ST builtin/camellia/OBJS.ST krb/OBJS.ST builtin/OBJS.ST
  + objlist=' builtin/enc_provider/des3.o builtin/enc_provider/rc4.o builtin/enc_provider/aes.o builtin/enc_provider/camellia.o
   builtin/hash_provider/hash_md4.o builtin/hash_provider/hash_md5.o builtin/hash_provider/hash_sha1.o builtin/hash_provider/hash_sha2.o
   builtin/md4/md4.o
   builtin/md5/md5.o
   builtin/sha1/shs.o
   builtin/sha2/sha256.o builtin/sha2/sha512.o
   builtin/aes/aescrypt.o builtin/aes/aestab.o builtin/aes/aeskey.o
   builtin/des/d3_aead.o builtin/des/d3_kysched.o builtin/des/des_keys.o builtin/des/f_aead.o builtin/des/f_cksum.o builtin/des/f_parity.o builtin/des/f_sched.o builtin/des/f_tables.o builtin/des/key_sched.o builtin/des/weak_key.o
   builtin/camellia/camellia.o
   krb/aead.o krb/block_size.o krb/cf2.o krb/checksum_dk_cmac.o krb/checksum_dk_hmac.o krb/checksum_etm.o krb/checksum_hmac_md5.o krb/checksum_unkeyed.o krb/checksum_length.o krb/cksumtype_to_string.o krb/cksumtypes.o krb/cmac.o krb/coll_proof_cksum.o krb/crypto_length.o krb/crypto_libinit.o krb/default_state.o krb/decrypt.o krb/decrypt_iov.o krb/derive.o krb/encrypt.o krb/encrypt_iov.o krb/encrypt_length.o krb/enctype_util.o krb/enc_dk_cmac.o krb/enc_dk_hmac.o krb/enc_etm.o krb/enc_raw.o krb/enc_rc4.o krb/etypes.o krb/key.o krb/keyblocks.o krb/keyed_cksum.o krb/keyed_checksum_types.o krb/keylengths.o krb/make_checksum.o krb/make_checksum_iov.o krb/make_random_key.o krb/mandatory_sumtype.o krb/nfold.o krb/old_api_glue.o krb/prf.o krb/prf_aes2.o krb/prf_cmac.o krb/prf_des.o krb/prf_dk.o krb/prf_rc4.o krb/prng.o krb/prng_fortuna.o krb/random_to_key.o krb/s2k_pbkdf2.o krb/s2k_rc4.o krb/state.o krb/string_to_cksumtype.o krb/string_to_key.o krb/valid_cksumtype.o krb/verify_checksum.o krb/verify_checksum_iov.o
   builtin/hmac.o builtin/init.o builtin/pbkdf2.o'
  + ar cq libk5crypto.a builtin/enc_provider/des3.o builtin/enc_provider/rc4.o builtin/enc_provider/aes.o builtin/enc_provider/camellia.o builtin/hash_provider/hash_md4.o builtin/hash_provider/hash_md5.o builtin/hash_provider/hash_sha1.o builtin/hash_provider/hash_sha2.o builtin/md4/md4.o builtin/md5/md5.o builtin/sha1/shs.o builtin/sha2/sha256.o builtin/sha2/sha512.o builtin/aes/aescrypt.o builtin/aes/aestab.o builtin/aes/aeskey.o builtin/des/d3_aead.o builtin/des/d3_kysched.o builtin/des/des_keys.o builtin/des/f_aead.o builtin/des/f_cksum.o builtin/des/f_parity.o builtin/des/f_sched.o builtin/des/f_tables.o builtin/des/key_sched.o builtin/des/weak_key.o builtin/camellia/camellia.o krb/aead.o krb/block_size.o krb/cf2.o krb/checksum_dk_cmac.o krb/checksum_dk_hmac.o krb/checksum_etm.o krb/checksum_hmac_md5.o krb/checksum_unkeyed.o krb/checksum_length.o krb/cksumtype_to_string.o krb/cksumtypes.o krb/cmac.o krb/coll_proof_cksum.o krb/crypto_length.o krb/crypto_libinit.o krb/default_state.o krb/decrypt.o krb/decrypt_iov.o krb/derive.o krb/encrypt.o krb/encrypt_iov.o krb/encrypt_length.o krb/enctype_util.o krb/enc_dk_cmac.o krb/enc_dk_hmac.o krb/enc_etm.o krb/enc_raw.o krb/enc_rc4.o krb/etypes.o krb/key.o krb/keyblocks.o krb/keyed_cksum.o krb/keyed_checksum_types.o krb/keylengths.o krb/make_checksum.o krb/make_checksum_iov.o krb/make_random_key.o krb/mandatory_sumtype.o krb/nfold.o krb/old_api_glue.o krb/prf.o krb/prf_aes2.o krb/prf_cmac.o krb/prf_des.o krb/prf_dk.o krb/prf_rc4.o krb/prng.o krb/prng_fortuna.o krb/random_to_key.o krb/s2k_pbkdf2.o krb/s2k_rc4.o krb/state.o krb/string_to_cksumtype.o krb/string_to_key.o krb/valid_cksumtype.o krb/verify_checksum.o krb/verify_checksum_iov.o builtin/hmac.o builtin/init.o builtin/pbkdf2.o
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_h.awk outfile=et-c-asn1_err.h et-c-asn1_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_c.awk outfile=et-c-asn1_err.c textdomain=mit-krb5 localedir= et-c-asn1_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_h.awk outfile=et-c-kdb5_err.h et-c-kdb5_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_c.awk outfile=et-c-kdb5_err.c textdomain=mit-krb5 localedir= et-c-kdb5_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_h.awk outfile=et-c-krb5_err.h et-c-krb5_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_c.awk outfile=et-c-krb5_err.c textdomain=mit-krb5 localedir= et-c-krb5_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_h.awk outfile=et-c-k5e1_err.h et-c-k5e1_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_c.awk outfile=et-c-k5e1_err.c textdomain=mit-krb5 localedir= et-c-k5e1_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_h.awk outfile=et-c-kv5m_err.h et-c-kv5m_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_c.awk outfile=et-c-kv5m_err.c textdomain=mit-krb5 localedir= et-c-kv5m_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_h.awk outfile=et-c-krb524_err.h et-c-krb524_err.et
  + awk -f /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/util/et/et_c.awk outfile=et-c-krb524_err.c textdomain=mit-krb5 localedir= et-c-krb524_err.et
  /Users/gen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krb5-src-0.3.3+1.19.2/krb5/src/lib/krb5/ccache/cc_kcm.c:51:10: fatal error: 'kcmrpc.h' file not found
  #include "kcmrpc.h"
           ^~~~~~~~~~
  1 error generated.
@benesch
Copy link
Member

benesch commented Jul 26, 2024

Hey, sorry—afraid we're not able to offer support for cross compiling issues in general, and in particular cargo zigbuild is not something we're familiar with. Happy to take a PR if you're able to debug this issue yourself, though. I'd start sniffing around here:

rust-krb5-src/build.rs

Lines 36 to 37 in 19f8473

host: env::var("HOST").unwrap(),
target: env::var("TARGET").unwrap(),

Perhaps cargo zigbuild doesn't set the TARGET environment variable as cargo build does?

@gen-xu
Copy link
Contributor Author

gen-xu commented Aug 7, 2024

Hey, sorry—afraid we're not able to offer support for cross compiling issues in general, and in particular cargo zigbuild is not something we're familiar with. Happy to take a PR if you're able to debug this issue yourself, though. I'd start sniffing around here:

rust-krb5-src/build.rs

Lines 36 to 37 in 19f8473

host: env::var("HOST").unwrap(),
target: env::var("TARGET").unwrap(),

Perhaps cargo zigbuild doesn't set the TARGET environment variable as cargo build does?

Thanks for reply and the hint, it does set the TARGET correctly though

Metadata { host: "aarch64-apple-darwin", target: "aarch64-unknown-linux-musl", build_dir: "/Users/gen/rust-krb5-src/target/aarch64-unknown-linux-musl/debug/build/krb5-src-66a2027f1b8020ae/out/build", install_dir: "/Users/gen/rust-krb5-src/target/aarch64-unknown-linux-musl/debug/build/krb5-src-66a2027f1b8020ae/out/install" }

I tried comment out following lines in build.rs and it worked afterwards for both cargo build --target aarch64-unknown-linux-musl and cargo zigbuild --target aarch64-unknown-linux-musl

        // If we're cross-compiling, let configure know.
        if metadata.host != metadata.target {
            configure_args.push(format!("--host={}", metadata.target));
        }

Instead of comment out, I also tried just change the configre args push line into

configure_args.push(format!("--host={}", metadata.host));

this also worked for both cargo build --target aarch64-unknown-linux-musl and cargo zigbuild --target aarch64-unknown-linux-musl

before this change neither commmands worked, created a PR for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants