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

cargo_without_cmake does not link with ld.bfd #223

Open
ahayzen-kdab opened this issue Aug 26, 2022 · 5 comments
Open

cargo_without_cmake does not link with ld.bfd #223

ahayzen-kdab opened this issue Aug 26, 2022 · 5 comments
Labels
🪲 bug Something isn't working 🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo ⬆️ upstream blocked on an upstream issue

Comments

@ahayzen-kdab
Copy link
Collaborator

Using ld with the cargo_without_cmake fails to link on Linux.

@ahayzen-kdab ahayzen-kdab added the 🪲 bug Something isn't working label Aug 26, 2022
@Be-ing
Copy link
Contributor

Be-ing commented Aug 26, 2022

I'm not sure there is anything we can do about this. I think it is a bug in GNU ld.

@ahayzen-kdab
Copy link
Collaborator Author

I'm not sure there is anything we can do about this. I think it is a bug in GNU ld.

Create a minimal example of the linking failure and report upstream to GNU ld to see if they have any ideas if it's a bug or something missing?

@Be-ing
Copy link
Contributor

Be-ing commented Sep 28, 2022

Here are the link errors with GNU ld:

error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "/tmp/rustcgqm0nC/symbols.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.1h8iyrq9nc5hjy66.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.1mt9xfcj10qy0y9g.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.1p1hzdjc2rmly6l9.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.1s4h681khl34bihf.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.1tf27nqjrjt5j0ng.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.1wj1dekcgf8w2c45.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.22aucna89swqjopd.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.25yrgy7q1u9pfd7f.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.2k5fbn8irlzyzvn0.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.2k7h5yjw44hk98tq.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.2lazy5h3nkfdby6t.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.2nzpbe9qouas5qm2.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.2ogbmglngedyeq0c.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.2pd0t5lafhm5kbc7.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.2wgzl85lh8s9wxw1.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.2wx3auulnix3bv1q.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.2yglqylmth9rc7g6.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.3426c2a9r2z62k7j.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.36lg7n2unkalf1ie.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.36wvnnlen3qcvhdh.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.384kclii0lc7tdi9.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.38mopze33m93h9s5.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.38yovcfeo4a22q7w.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.3ci1td78pvpz25cr.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.3g6tapi5ssy0ndot.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.3gbj4a7fwvutt0t7.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.3hfcnk4vryhaylr3.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.3i36skgy7b7wo2ss.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.3jp45zjn929guht8.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.3mz6nwtmr0pfycxd.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.3pgiunr8tsr3y6js.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.3w7lioskb51iw9p6.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.3yom3hloykdzs1fl.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.430cjy60utrab8cc.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.46qxtbq9cbu5bere.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.4eu1qg8b7n9r2m8c.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.4g3b2wo4doeob1ph.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.4ku17djk8wb68wez.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.4opsjc4fj9r88icm.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.4qb7ip65ebgmkwis.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.4rkggtep58j58vb3.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.4vn8aoufhsr6cve3.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.4xz2nlhapi2o5jkk.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.50hyl4r6c960q47o.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.51l3rv9ktmd4wpnf.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.51o8fa7d5juz3ni.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.52mv13g8782uhwm7.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.56ikzvsm4okhqqs0.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.5aql96veddgi8sm4.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.5c1m7euyx8l96qgb.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.5c1ypfefqmmji0jj.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.5e7cvoxvxlhit4ox.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.fsc0cwhhscsxh4p.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.ic47u0phy8uovcu.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.k7gwupop2wpyill.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.llk1dn2wan0kgqz.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.y403cnbuikq4mqg.rcgu.o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3.38pbifuqyjcwup6o.rcgu.o" "-Wl,--as-needed" "-L" "/home/be/sw/cxx-qt/target/debug/deps" "-L" "/usr/lib64" "-L" "/home/be/sw/cxx-qt/target/debug/build/qml-minimal-no-cmake-29c8de0c6f6e43e3/out" "-L" "/home/be/sw/cxx-qt/target/debug/build/cxx-3c36e17d3db42728/out" "-L" "/home/be/sw/cxx-qt/target/debug/build/link-cplusplus-d55b9af80b7e3623/out" "-L" "/usr/lib64" "-L" "/home/be/sw/cxx-qt/target/debug/build/cxx-qt-lib-307fa3930074bcd7/out" "-L" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lQt6Network" "-lQt6Qml" "-lQt6Gui" "-lQt6Core" "-Wl,-Bstatic" "-lcxx-qt-gen" "-Wl,-Bdynamic" "-lstdc++" "-Wl,-Bstatic" "/home/be/sw/cxx-qt/target/debug/deps/libcxx_qt_lib-d9853f3bf6e6f95b.rlib" "/home/be/sw/cxx-qt/target/debug/deps/libcxx-be808adb27e7e24d.rlib" "/home/be/sw/cxx-qt/target/debug/deps/liblink_cplusplus-b8eedc8afd5892f7.rlib" "-Wl,--start-group" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-5670385a2fe8b60b.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-fd56ba6dbf7aaecc.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-b8acf8e5c2e85baa.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-1706edefffdca0a2.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-f483302e0b13708e.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-725b0718fc18e1ed.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-de685fcf2157e6fb.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-f613ac3eda05b9ff.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-3de98a7d049af6a1.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-c12183655bdce152.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-0fc7beea925de7e3.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-8c34825485bf59dc.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-ba5f7e926e729d81.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-643de0950163a839.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-539ea2f72ef89687.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-871432094bb4c885.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-ef1a8ee61f2e39bf.rlib" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-f1646747442c1c7b.rlib" "-Wl,--end-group" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-ff283b4bf550fa1c.rlib" "-Wl,-Bdynamic" "-lQt6Core" "-lQt6Gui" "-lstdc++" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/be/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/be/sw/cxx-qt/target/debug/deps/qml_minimal_no_cmake-25e604b0524707e3" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs"
  = note: /usr/bin/ld: /home/be/sw/cxx-qt/target/debug/build/qml-minimal-no-cmake-29c8de0c6f6e43e3/out/libcxx-qt-gen.a(run.o): in function `run_cpp':
          /home/be/sw/cxx-qt/examples/cargo_without_cmake/src/cpp/run.cpp:40: undefined reference to `QQmlApplicationEngine::QQmlApplicationEngine(QObject*)'
          /usr/bin/ld: /home/be/sw/cxx-qt/examples/cargo_without_cmake/src/cpp/run.cpp:43: undefined reference to `QQmlApplicationEngine::objectCreated(QObject*, QUrl const&)'
          /usr/bin/ld: /home/be/sw/cxx-qt/examples/cargo_without_cmake/src/cpp/run.cpp:55: undefined reference to `QQmlApplicationEngine::load(QUrl const&)'
          /usr/bin/ld: /home/be/sw/cxx-qt/examples/cargo_without_cmake/src/cpp/run.cpp:58: undefined reference to `QQmlApplicationEngine::~QQmlApplicationEngine()'
          /usr/bin/ld: /home/be/sw/cxx-qt/examples/cargo_without_cmake/src/cpp/run.cpp:58: undefined reference to `QQmlApplicationEngine::~QQmlApplicationEngine()'
          /usr/bin/ld: /home/be/sw/cxx-qt/target/debug/build/qml-minimal-no-cmake-29c8de0c6f6e43e3/out/libcxx-qt-gen.a(run.o): in function `std::enable_if<(QtPrivate::FunctionPointer<run_cpp::$_0>::ArgumentCount==(-(1)))&&(!std::is_convertible_v<run_cpp::$_0, char const*>), QMetaObject::Connection>::type QObject::connect<void (QQmlApplicationEngine::*)(QObject*, QUrl const&), run_cpp::$_0>(QtPrivate::FunctionPointer<void (QQmlApplicationEngine::*)(QObject*, QUrl const&)>::Object const*, void (QQmlApplicationEngine::*)(QObject*, QUrl const&), QObject const*, run_cpp::$_0, Qt::ConnectionType)':
          /usr/include/qt6/QtCore/qobject.h:339: undefined reference to `QQmlApplicationEngine::staticMetaObject'
          /usr/bin/ld: /home/be/sw/cxx-qt/target/debug/build/qml-minimal-no-cmake-29c8de0c6f6e43e3/out/libcxx-qt-gen.a(run.o): in function `int qmlRegisterType<MyObject>(char const*, int, int, char const*)':
          /usr/include/qt6/QtQml/qqml.h:348: undefined reference to `QQmlPrivate::qmlregister(QQmlPrivate::RegistrationType, void*)'
          /usr/bin/ld: /home/be/sw/cxx-qt/target/debug/build/qml-minimal-no-cmake-29c8de0c6f6e43e3/out/libcxx-qt-gen.a(run.o): in function `~QQmlElement':
          /usr/include/qt6/QtQml/qqmlprivate.h:134: undefined reference to `QQmlPrivate::qdeclarativeelement_destructor(QObject*)'
          collect2: error: ld returned 1 exit status
          
  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

@ahayzen-kdab
Copy link
Collaborator Author

It has been found that ld.gold works but ld.bfd does not work, limiting the impact of this bug.

@Be-ing Be-ing added the 🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo label Jul 7, 2023
@Be-ing
Copy link
Contributor

Be-ing commented Jul 7, 2023

The mitigation for this is to call setup_linker which tells Cargo to lld, ld.gold, or mold in preference to ld.bfd.

@Be-ing Be-ing changed the title cargo_without_cmake does not link with ld only ldd or mold on Linux cargo_without_cmake does not link with ld.bfd Jul 7, 2023
@Be-ing Be-ing added the ⬆️ upstream blocked on an upstream issue label Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪲 bug Something isn't working 🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo ⬆️ upstream blocked on an upstream issue
Projects
None yet
Development

No branches or pull requests

2 participants