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

Cannot cross-compile rust while providing pre-built LLVM #134811

Open
rhelmot opened this issue Dec 27, 2024 · 8 comments · May be fixed by #134913
Open

Cannot cross-compile rust while providing pre-built LLVM #134811

rhelmot opened this issue Dec 27, 2024 · 8 comments · May be fixed by #134913
Labels
A-cross Area: Cross compilation C-bug Category: This is a bug. O-NixOS Operating system: NixOS, https://nixos.org/ T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@rhelmot
Copy link

rhelmot commented Dec 27, 2024

I'm a little lost at how exactly to report this because I don't fully understand the error - I've spent several hours trying to reverse engineer the build process and the following is all I really have to show for it:

I'm trying to simplify the nixpkgs build of rustc, and I'm getting failures in cross configurations (linux x86_64->aarch64 as my testcase). This build configuration requires using pre-built LLVMs and providing the llvm-config binary for each target in a cross build. I'm getting build failures when linking the stage2:x86_64-unknown-linux-gnu -> stage3:aarch64-unknown-linux-gnu rust-analyzer-proc-macro-srv, claiming that it can't find -lLLVM-19. Before this, it was successfully able to link the stage1:x86_64-unknown-linux-gnu -> stage2:aarch64-unknown-linux-gnu rustc_driver against libLLVM-19.so for the aarch64 platform without any issue.

I was able to determine that it's deciding it needs to link with -lLLVM-19 because of some data in the librustc_llvm.rmeta file - when I edited the rmeta file to say LLBM instead, the error message changed accordingly but still failed in the same spot. Based on this, it seems like the underlying bug is that the corresponding -L path flags aren't being propagated even though the -l flags are.

However, I haven't been able to determine why it does work in the non-cross case. I give it equal odds my hypothesis is just wrong vs there is some special cross/non-cross logic in the rustc build which is messing this up.

Note: I tried jamming the is_cross predicate in the rustc_llvm build script to false, since the comments around it seemed to not match super well for my nix use-case, but it failed the same way.

Here's the config.toml (gzip'd to make github happy) for my build

Here's the build log for the failing build

llvm-config output:

[+] ~/proj/nix/nixpkgs% /nix/store/6b44i6knzdd71qkjygd8gjwzq00x3ipl-llvm-aarch64-unknown-linux-gnu-19.1.6-dev/bin/llvm-config-native --ldflags
-L/nix/store/5bck4qix6xd3hf4rkjfxcga6w4n8ks6y-llvm-aarch64-unknown-linux-gnu-19.1.6-lib/lib 
[+] ~/proj/nix/nixpkgs% /nix/store/6b44i6knzdd71qkjygd8gjwzq00x3ipl-llvm-aarch64-unknown-linux-gnu-19.1.6-dev/bin/llvm-config-native --libs
-lLLVM-19
[+] ~/proj/nix/nixpkgs% /nix/store/dqq9r3nggw20fqs3lsyci7m5pskqp7xh-llvm-19.1.6-dev/bin/llvm-config --ldflags
-L/nix/store/7g1gw5zkssblpcbgicnnbvwpbmr4za55-llvm-19.1.6-lib/lib 
[+] ~/proj/nix/nixpkgs% /nix/store/dqq9r3nggw20fqs3lsyci7m5pskqp7xh-llvm-19.1.6-dev/bin/llvm-config --libs
-lLLVM-19

If anyone would like to reproduce this with nix, you can do so with nix build github:rhelmot/nixpkgs/04a5a2d2fb5216c0f401529d08a1c034fcbd890d#pkgsCross.aarch64-multiplatform.rustc.unwrapped. It's based on a staging branch of nixpkgs, so it will have to rebuild the world and will take a few hours.

Lemme know if there's anything else I can provide.

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 27, 2024
@workingjubilee workingjubilee added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) A-cross Area: Cross compilation C-bug Category: This is a bug. labels Dec 27, 2024
@saethlin saethlin added the O-NixOS Operating system: NixOS, https://nixos.org/ label Dec 27, 2024
@jyn514
Copy link
Member

jyn514 commented Dec 27, 2024

you have provided llvm-config flags for the host, but not for the aarch64 target. can you post the output of /nix/store/6b44i6knzdd71qkjygd8gjwzq00x3ipl-llvm-aarch64-unknown-linux-gnu-19.1.6-dev/bin/llvm-config-native --ldflags --libs?

However, I haven't been able to determine why it does work in the non-cross case. I give it equal odds my hypothesis is just wrong vs there is some special cross/non-cross logic in the rustc build which is messing this up.

non-cross builds use a different version of llvm, one that's compiled for the host and not the target. note that you have this output in your build log:

 "-L" "/build/rustc-1.83.0-src/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib"

i'm not entirely why rustc is trying to link an artifact against llvm. my best guess is that proc-macro-srv is weird because it links against rustc and therefore needs to link against rustc's dynamic libraries. you could try passing --exclude proc-macro-srv and see if this error happens for any other artifact.

can you post the output of ls /build/rustc-1.83.0-src/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib? i think it will be empty; i think what's happened is that bootstrap respects target.aarch64.llvm-config when building rustc itself, but something goes wrong when rustc is compiling an artifact for that target.

@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 27, 2024
@rhelmot
Copy link
Author

rhelmot commented Dec 27, 2024

can you post the output of /nix/store/6b44i6knzdd71qkjygd8gjwzq00x3ipl-llvm-aarch64-unknown-linux-gnu-19.1.6-dev/bin/llvm-config-native --ldflags --libs?

Was this from the original post not what you're looking for?

[+] ~/proj/nix/nixpkgs% /nix/store/6b44i6knzdd71qkjygd8gjwzq00x3ipl-llvm-aarch64-unknown-linux-gnu-19.1.6-dev/bin/llvm-config-native --ldflags
-L/nix/store/5bck4qix6xd3hf4rkjfxcga6w4n8ks6y-llvm-aarch64-unknown-linux-gnu-19.1.6-lib/lib 
[+] ~/proj/nix/nixpkgs% /nix/store/6b44i6knzdd71qkjygd8gjwzq00x3ipl-llvm-aarch64-unknown-linux-gnu-19.1.6-dev/bin/llvm-config-native --libs
-lLLVM-19

Working on getting you the rest. /build is a bindmount to a /tmp directory that got cleared on reboot, so I'm regenerating it right now.

@rhelmot
Copy link
Author

rhelmot commented Dec 27, 2024

The directory you asked to list was decidedly not empty:

ls /build/rustc-1.83.0-src/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib
libaddr2line-4947e6d1ed4e28e8.rlib
libadler2-5909a9b4e36bcf9c.rmeta
libadler-fa918eddbf883174.rlib
libahash-4899055c9601d868.rmeta
libaho_corasick-c7035db266ee63d0.rmeta
liballocator_api2-fadea7b41359608c.rmeta
liballoc-c8d8feeffdb4b1eb.rlib
libannotate_snippets-365bff9162d249b7.rmeta
libannotate_snippets-fa6e15c7e5618a32.rmeta
libanstyle-a650fe8acd3c6b7c.rmeta
libanstyle-ee065727556ed759.rmeta
libar_archive_writer-0adeeb690b7b3a53.rmeta
libarrayref-6926ef0124ff0a1b.rmeta
libarrayvec-ee3185355edb89ad.rmeta
libbitflags-417ee0452bfb388e.rmeta
libbitflags-8882eb1181bca182.rmeta
libblake3-0635b2f2e7fedcf5.rmeta
libblock_buffer-b7674a6e8908aadb.rmeta
libbyteorder-65a1faa0232c2b2b.rmeta
libcc-2c4cb4be0f50a449.rmeta
libcfg_if-050ca7158b244f01.rlib
libcfg_if-9fdf95d2d3cc58f2.rmeta
libcompiler_builtins-8611e7787b2b94d7.rlib
libconstant_time_eq-7ae9812a114ee956.rmeta
libcore-b5a266bb334ff783.rlib
libcpufeatures-5e1f2f9ae51efa65.rmeta
libcrc32fast-c650811449b6cd0f.rmeta
libcrypto_common-1265f117a7be7a3b.rmeta
libctrlc-3ab285dee4eec4a9.rmeta
libdarling-5e442d21d5713730.rmeta
libdarling_core-40c82daabe33843d.rmeta
libdarling_macro-a158a5ee98f71c79.so
libdatafrog-eeba511b54f21f85.rmeta
libderanged-2795569586847cba.rmeta
libderive_setters-24ba29d4c896af55.so
libderive_where-1ddaff60091eca20.so
libdigest-ab1e781ddad1c6aa.rmeta
libdisplaydoc-66d57e063986f591.so
libeither-1725e4a6ccb08b5f.rmeta
libelsa-0d8cd11d9eff1cbc.rmeta
libena-4efe649eb449f73f.rmeta
libequivalent-63dcd4ae9d67885b.rmeta
libfastrand-1a45c5f7c738dbb3.rmeta
libfield_offset-d9e0be79495419c2.rmeta
libflate2-408571a9e0621ef1.rmeta
libfluent_bundle-6434842154b13085.rmeta
libfluent_bundle-8fac3db5e574bbab.rmeta
libfluent_langneg-101015ebf5ce557f.rmeta
libfluent_langneg-116feb7b7dac8410.rmeta
libfluent_syntax-d28ff037eec580a5.rmeta
libfluent_syntax-edca0d25d7af357d.rmeta
libfnv-022625e35db4cb25.rmeta
libgeneric_array-23e1a8c3fdbc6ab1.rmeta
libgetopts-1ed4c696ecced58a.rlib
libgetopts-c23f549384a83692.rmeta
libgetrandom-a55b47dc51d71d08.rmeta
libgimli-1b8b7c913ff3aab3.rmeta
libgimli-e87aace83eb8c8ca.rlib
libgsgdt-e503ddbf857d24c2.rmeta
libhashbrown-3d0a0cd78014a2a0.rlib
libhashbrown-df02c2aba7112ccc.rmeta
libicu_list-d13c95afbc6367e2.rmeta
libicu_list_data-15706113e635424a.rmeta
libicu_locid-a414f53ba50c3e34.rmeta
libicu_locid_transform-768b61615ec6d7ea.rmeta
libicu_locid_transform_data-4979479f9067bfcb.rmeta
libicu_provider-2be328ec8ef0823d.rmeta
libicu_provider_adapters-c648b4e6c0d0db69.rmeta
libicu_provider_macros-dcd7edade3986586.so
libident_case-8fb4f981a12dc333.rmeta
libindexmap-c6e26620f075f097.rmeta
libintl_memoizer-88a41f587caf5290.rmeta
libintl_memoizer-909cb7bb4dfaa1f7.rmeta
libintl_pluralrules-6730faed4d3cbc7e.rmeta
libintl_pluralrules-eaf34330e377af7e.rmeta
libitertools-3ae2757246b59f93.rmeta
libitoa-0e21eb9bdbffaee4.rmeta
libjobserver-f85e2adf44e92468.rmeta
liblazy_static-dfbd3c38695c0d5f.rmeta
libleb128-2d70fae5a29f0b65.rmeta
liblibc-562d74a742aa2518.rlib
liblibc-daea6ad78325feca.rmeta
liblibloading-1a8566f0c9401a17.rmeta
liblinux_raw_sys-639687c40b7f30bb.rmeta
liblitemap-a531ca5ab8fac26c.rmeta
liblock_api-52bec74c3688e05b.rmeta
liblog-d9dbd233a26aa5c0.rmeta
libmatchers-7118639d8b57d65c.rmeta
libmd5-409d922690f34ea4.rmeta
libmeasureme-ccaafadb265ec31b.rmeta
libmemchr-0d827c5eceac4ac8.rlib
libmemchr-5c59f264851d5293.rmeta
libmemmap2-18dc6b1a95d3b4d2.rmeta
libmemoffset-6c79c3a014555ccb.rmeta
libminiz_oxide-0a2a9b6e0a1d17e1.rlib
libminiz_oxide-9f2e944cf47fb047.rmeta
libnix-28468e22cde8caf6.rmeta
libnu_ansi_term-11bedcfd61874bce.rmeta
libnu_ansi_term-37515aa9b6e1d62c.rmeta
libnum_conv-c5710c1f8c41f05f.rmeta
libnum_conv-f35a8e01e92fdcb0.rmeta
libobject-07c7665c8601d557.rmeta
libobject-7b1f2ac8068f1f45.rlib
libodht-788b69473eaf27a4.rmeta
libonce_cell-49fcd7573227371c.rmeta
liboverload-d0140f02f1022c89.rmeta
libpanic_abort-c1c0f5a64cbfd63e.rlib
libpanic_unwind-c648b74ae9ea7936.rlib
libparking_lot-527fceab8afdea7c.rmeta
libparking_lot_core-68d1e08eaeab172d.rmeta
libpathdiff-15c1143c91d22ce1.rmeta
libpin_project_lite-0cba3b5972cfe15c.rmeta
libpolonius_engine-f699ec0d3ce5b07f.rmeta
libpowerfmt-69256d45029643ae.rmeta
libppv_lite86-3843eb210c4e161c.rmeta
libproc_macro2-14cfc503e0e6098c.rmeta
libproc_macro-b28b830c3c04cf64.rlib
libproc_macro_hack-b90c9ca9589b9a1c.so
libprofiler_builtins-f61f2849a8bf6252.rlib
libpsm-cae3a97bb5c0f679.rmeta
libpulldown_cmark-7c548e5c4e2f82a3.rmeta
libpulldown_cmark_escape-915c5c3d9cd73bbb.rmeta
libpunycode-9ae7fb84534df621.rmeta
libquote-77248ab7a1e6b494.rmeta
librand_chacha-2d33223e4b6053cc.rmeta
librand_core-7a99eb79c05d2f91.rmeta
librand-e8b1c64d7d25f538.rmeta
librand_xoshiro-4aa82f56a97f5480.rmeta
libregex-76e76557b83f2e33.rmeta
libregex_automata-5ecb87d6afe05e77.rmeta
libregex_automata-e7800a1de3d95e17.rmeta
libregex_automata-f4af79faf0109bba.rmeta
libregex_syntax-6865595ec540bb94.rmeta
libregex_syntax-e4fbf0f1d39ea87d.rmeta
librustc_abi-08cac592157aa4bc.rmeta
librustc_apfloat-bdfc782a66cac252.rmeta
librustc_arena-cfd00e316c10d5cf.rmeta
librustc_ast-47ad2ccd251aba6f.rmeta
librustc_ast_ir-aeb0270e0f1fb3c9.rmeta
librustc_ast_lowering-42e310bb2cacab8d.rmeta
librustc_ast_passes-feb4e643aa090b97.rmeta
librustc_ast_pretty-ca67ff92bb67b093.rmeta
librustc_attr-ab8f207e66e4d30f.rmeta
librustc_baked_icu_data-d51e379e6af31d66.rmeta
librustc_borrowck-9629933c691892fc.rmeta
librustc_builtin_macros-18522ce33f7c3b2f.rmeta
librustc_codegen_llvm-81b65f788c1e7223.rmeta
librustc_codegen_ssa-df01e69a6eb1962f.rmeta
librustc_const_eval-1b664ab46e6346ee.rmeta
librustc_data_structures-c041c5e8ce1ed26b.rmeta
librustc_demangle-90d556cb94a73475.rmeta
librustc_demangle-b5586794ac104ff8.rlib
librustc_driver-080ff609469c8575.so
librustc_driver_impl-8a969ecd1ffcf4d4.rmeta
librustc_error_codes-1bb5d221b3c744c9.rmeta
librustc_error_messages-0718239ca6918abf.rmeta
librustc_errors-bfb041b7a81b062a.rmeta
librustc_expand-135eff6c694eadc1.rmeta
librustc_feature-742663f94c44f510.rmeta
librustc_fluent_macro-df6bd99243f1699d.so
librustc_fs_util-01f922c96f1e9dff.rmeta
librustc_graphviz-182ea29ac44c776a.rmeta
librustc_hash-7f03005fec745059.rmeta
librustc_hash-9ad4f655286119ba.rmeta
librustc_hir-14a0a3de7716d184.rmeta
librustc_hir_analysis-59f023d427facdf6.rmeta
librustc_hir_pretty-e61b7567784e28d2.rmeta
librustc_hir_typeck-ab8910925ba9bfda.rmeta
librustc_incremental-036addc6ca3a9af7.rmeta
librustc_index-5e58514e5e36589d.rmeta
librustc_index_macros-67cb292fa4731e9e.so
librustc_infer-d5cf926a8f738138.rmeta
librustc_interface-a57f2e3983a1ffed.rmeta
librustc_lexer-5bfd1807bb893c96.rmeta
librustc_lint-ab65d2b603bbbb93.rmeta
librustc_lint_defs-392e5581ef83358d.rmeta
librustc_llvm-6e332c58880aed01.rmeta
librustc_log-6310e62382a4d170.rmeta
librustc_macros-c735bcb5cbc38e6b.so
librustc_metadata-55276c1d5b363f94.rmeta
librustc_middle-ef83045a3af10252.rmeta
librustc_mir_build-e1d1874ae5663889.rmeta
librustc_mir_dataflow-9d00edf58a6973b6.rmeta
librustc_mir_transform-3fc84736a4864b3b.rmeta
librustc_monomorphize-a8b9d6681a7e6694.rmeta
librustc_next_trait_solver-04952a2d88c13505.rmeta
librustc_parse-9048bf691168225d.rmeta
librustc_parse_format-0d224fa41ab6bb80.rmeta
librustc_passes-15e4773e661bd7f2.rmeta
librustc_pattern_analysis-df04488f0af5dbaf.rmeta
librustc_privacy-1e226ad2a17e7682.rmeta
librustc_query_impl-5f2f24a35dba93ef.rmeta
librustc_query_system-285ee14988a2ef14.rmeta
librustc_resolve-40d1febc61ed0715.rmeta
librustc_sanitizers-e74fa4fc5165c772.rmeta
librustc_serialize-ae8c325b585074f3.rmeta
librustc_session-601ccba79c64979b.rmeta
librustc_smir-fa8da67541aad19f.rlib
librustc_span-9a6342ea73c1dbe5.rmeta
librustc_stable_hash-d60ea0f187a99150.rmeta
librustc_std_workspace_alloc-d278f68be1dac370.rlib
librustc_std_workspace_core-f7a0a0f998e98073.rlib
librustc_std_workspace_std-1f24452fc6819a94.rlib
librustc_symbol_mangling-30986c05d271bfd3.rmeta
librustc_target-1856fd5b70e6cb8a.rmeta
librustc_traits-8e9cebec53e07686.rmeta
librustc_trait_selection-1fff6fe0de9624dd.rmeta
librustc_transmute-e090db49db8f8ed4.rmeta
librustc_type_ir-35a90949404f8995.rmeta
librustc_type_ir_macros-f62be18fd241cd8b.so
librustc_ty_utils-b207f5c9aa2db9e2.rmeta
librustix-de242976a8a84c70.rmeta
libruzstd-00f0e23a4b5f12f7.rmeta
libryu-88b4f6a341b83e44.rmeta
libscoped_tls-2dc417e1f061cb33.rmeta
libscopeguard-a69adec0d1d6eb2e.rmeta
libself_cell-06433304684b5f8b.rmeta
libself_cell-66fd7ce8abdbab3e.rmeta
libself_cell-9e801f298ae54078.rmeta
libself_cell-f04eddb58b84dea0.rmeta
libserde-c1d419f3e0ee615b.rmeta
libserde_derive-395c532770c2170d.so
libserde_json-fdda82da27afa6e9.rmeta
libsha1-cbf80ea4514a57b8.rmeta
libsha2-b3300fa356cc69b3.rmeta
libsharded_slab-e419dae808ffe7bb.rmeta
libshlex-c05759688f44b3e5.rmeta
libsmallvec-9f5994208184957b.rmeta
libsmallvec-b43040fc274f0d75.rmeta
libsnap-0b99641efdca4d58.rmeta
libstable_deref_trait-22c5cd8d6900a5af.rmeta
libstable_mir-c013c29fd425a30d.rlib
libstacker-e34652c054d15624.rmeta
libstatic_assertions-0f37129963fa4d9c.rmeta
libstd_detect-1dc2faa4dc0a0b59.rlib
libstd-fb20ce1195817444.rlib
libstd-fb20ce1195817444.so
libstrsim-3f9f8b97ab2f148e.rmeta
libsyn-b5423184e32a1999.rmeta
libsynstructure-6e44c648cebc40a1.rmeta
libsysroot-023643e40c2b5432.rlib
libtempfile-bcbf8ab3a9cb6618.rmeta
libtermcolor-09b0959cbbdc08f1.rmeta
libtermize-5abf2cd877002d9f.rmeta
libtest-f95ef414ce72a11b.rlib
libthin_vec-d8a5506b89c58252.rmeta
libthiserror-18547bd4c5b82d74.rmeta
libthiserror-909f2b2be4af3d86.rmeta
libthiserror_impl-02c912dd94625fdb.so
libthorin-01090ba84e5f55e5.rmeta
libthread_local-5420497730bfc464.rmeta
libtime-81652204ee45d283.rmeta
libtime_core-2f34284bc4161019.rmeta
libtime_core-d58e1860b28339bd.rmeta
libtime_macros-6e609c2fcd74c09b.so
libtinystr-2aa3f5bb560e993b.rmeta
libtinystr-4a6cd1cdba14b223.rmeta
libtinyvec-5d10a72420259a6a.rmeta
libtinyvec_macros-d34e33beaa7d2c36.rmeta
libtracing-793271c3336f0302.rmeta
libtracing_attributes-14bfa736d8cafa1c.so
libtracing_core-d685c8ce76c1057f.rmeta
libtracing_log-65e78a2f499ce64d.rmeta
libtracing_subscriber-1ae5f2b257c74c4e.rmeta
libtracing_tree-06e812715994960d.rmeta
libtwox_hash-42a5292a769b8dcd.rmeta
libtype_map-12af1ca4af8156ca.rmeta
libtype_map-17818de0feb78435.rmeta
libtypenum-b70ae7856f8bf15c.rmeta
libunicase-ee085e46e739ef98.rmeta
libunic_langid-457917c73e9c40f1.rmeta
libunic_langid-4e88ce6594e644bc.rmeta
libunic_langid_impl-4bcefee5bbb9f229.rmeta
libunic_langid_impl-cf5e2353084c698e.rmeta
libunic_langid_macros-8c6cdc5d54e152b2.rmeta
libunic_langid_macros-d5fcd2e86457078b.rmeta
libunic_langid_macros_impl-357e9a9dffac73d0.so
libunicode_ident-95a0f9ac28d9da6f.rmeta
libunicode_normalization-511700118a6532d6.rmeta
libunicode_properties-913142bcd0b5a22c.rmeta
libunicode_script-563b923235ebc6e7.rmeta
libunicode_security-db5ceb16eaf968e0.rmeta
libunicode_width-108608804af5e299.rmeta
libunicode_width-26d0c2e04f6ea5b4.rlib
libunicode_width-2fed62abe02e4cf9.rmeta
libunicode_width-b812706a9cf7eb3d.rmeta
libunicode_xid-6ebb97796e4c7d72.rmeta
libunwind-ab44adc55153e80d.rlib
libwasm_encoder-fe7c11a47b805a75.rmeta
libwasmparser-83a7cb54c72e9abb.rmeta
libwriteable-9012831f27e44e67.rmeta
libyoke-976001ad80453a88.rmeta
libyoke_derive-a0fee245a4e44c41.so
libzerocopy-96521884d36b85be.rmeta
libzerocopy_derive-e1bd3580bfd08245.so
libzerofrom-de8fd0e7d698d6ce.rmeta
libzerofrom_derive-288fd0038789f6f6.so
libzerovec-837fa3513b706dc8.rmeta
libzerovec_derive-932abb5438987cd0.so
self-contained

I am going to need some more detailed instructions on how to get a build without proc-macro-srv - both python3 ./x.py build --exclude rust-analyzer-proc-macro-srv and python3 ./x.py build --exclude proc-macro-srv fail in the same way.

@jyn514
Copy link
Member

jyn514 commented Dec 27, 2024

The directory you asked to list was decidedly not empty:

it doesn't have libLLVM.so though, that's what i was looking for. on my local build, which doesn't set llvm-config, it does contain libLLVM:

; fd libLLVM build/host/stage1/lib
build/host/stage1/lib/libLLVM-19-rust-dev.so
build/host/stage1/lib/libLLVM.so.19.1-rust-dev
build/host/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-19-rust-dev.so
build/host/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM.so.19.1-rust-dev

so bootstrap notices that you have llvm-config set for this target, but it's using it inconsistently. i don't have time to trawl through the code right now but

add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cargo);
looks related, maybe llvm_config is wrong in that branch or something.

I am going to need some more detailed instructions on how to get a build without proc-macro-srv - both python3 ./x.py build --exclude rust-analyzer-proc-macro-srv and python3 ./x.py build --exclude proc-macro-srv fail in the same way.

ah my bad, it's proc-macro-srv-cli for some reason.

@rhelmot
Copy link
Author

rhelmot commented Dec 30, 2024

I set RUSTC_ON_FAIL=env and determined that the effect of the line you linked is present and correct, that is, I see LIBRARY_PATH=/nix/store/5bck4qix6xd3hf4rkjfxcga6w4n8ks6y-llvm-aarch64-unknown-linux-gnu-19.1.6-lib/lib in the output when linking fails.

@rhelmot
Copy link
Author

rhelmot commented Dec 30, 2024

...LIBRARY_PATH seems to be explicitly ignored in clang when cross compiling? https://github.com/llvm/llvm-project/blob/llvmorg-19.1.6/clang/lib/Driver/ToolChains/CommonArgs.cpp#L453-L456

@jyn514
Copy link
Member

jyn514 commented Dec 30, 2024

@rhelmot does it work if you explicitly pass -C link-arg=-L… instead? i think we’d take a patch for that.

@rhelmot
Copy link
Author

rhelmot commented Dec 30, 2024

Seems to work. Let's do it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cross Area: Cross compilation C-bug Category: This is a bug. O-NixOS Operating system: NixOS, https://nixos.org/ T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants