Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

RUSTFLAGS Linker Flags Order #57837

Copy link
Copy link
@LukeMauldin

Description

@LukeMauldin
Issue body actions

Linker flags specified by RUSTFLAGS are added to end of the command. Need a way to add at beginning.

I have a simple rust program that compiles against multiple vendor provided shared libraries. I need to link against the shared libraries with the --no-as-needed flag because the dependencies of the shared libaries are not setup correctly. I do not have the source code to the libraries and I cannot recompile them.

This is an example of linking a simple C++ program against the libraries. Notice the --no-as-needed flag is at the start of the command.

/usr/bin/gcc -m64 -L/apps/tc9/lib -L/apps/tc9/lib/oracle -L/usr/lib -L/usr/lib64 -L/usr/lib /apps/tc9/lib/itk_main.o main.o -Wl,--no-as-needed -L/apps/tc9/lib -luser_exits -lgdis -leintstub -lnxmgr_im -linternal_exits -lae -laie -lappr -larchive -lvis -lvm -lbackup -lbmf -lbob -lbom -lcae -lcfm -lconfig -lcxpom -ldmi -lmgc -lecm -leint -lepm -lfclasses -lform -lgrm -ltcinit -ltc -lsml -ltccore -ltctrushape -lqsearch -litk -lbase_utils -lics -llov -lme -lmld -lobjio -love -lproperty -lps -lpublication -lpie -lai -lqry -lres -lreq -ladsfoundation -ltcsoacorestrong -lsa -lschmgt -lschmgt_bridge -lss -lvispublish -lsub_mgr -lclientcache -ltextsrv -lrdv -lTcCrypto -ltcsso -lcollabctx -lmechatronics -ldocmgtapp -lcontmgmt -lserver_exits -linternal_server_exits -ltcgsoap -laiwebservice -ltcxsd -lconfigurator -ltcsoacommon -ltcsoaclient -ltcgateway -ltcsoaserver -ltcserverutil -lvalidation -lcp -ltcmultisitetypes -ltcmultisitestrong -ltcsoaworkflow -ltcsoaworkflowtypes -ltcsoaworkflownative -ltc_utils -ltccoreext -lrbf -lce -lclips -lclipsutil -lgms -ltie -lbriefcase -lvisualization -lnxclone -lvendormanagementdispatch -lccdm -lproductvariant -lfunctionality -licsie -lcondvalidation -lsmartuibldr -lfnd0soadiagramming -lfnd0soadiagrammingtypes -ltcsoacoretypes -ltcsoacore -ltcsoaprojectmanagement -ltcsoaprojectmanagementtypes -ltcsoaprojectmanagementnative -lbmidebase -lpdi_corba_server -lict -lcba -lsharedcache -lsharedcachetypes -lbooleanmath -lcbaext -lcfilter -lfnd0booleansolve -ldispatcher -lmeta -lmetaframework -lsecore -lfoundationdispatch -lcmdispatch -lcm -lFnd0nweditor -lusagewc -lusage -lconstants -lmfg -lmfgbvr -lssrsccuaclient -lscmccdispatch -lextensionframework -ldocmgt -lissuemgmt -lfunctionality -lcondvalidation -lFnd0profiler -lFnd0formulamgmt -larm -lpom -lsyss -lugmath -lplmxmlSDK -lplmxmlExtensions -lplmContainerSDK -licui18n341 -lxerces270 -lxalan110 -lc -lm -ldl -lnsl -lelf -lresolv -lclntsh -ldb2 -lstdc++ -Wl,--unresolved-symbols=ignore-in-shared-libs -o main_ubuntu

I have set the RUSTFLAGS variable via ./.cargo/config:

[build]
rustflags = [
"-C", "link-arg=-Wl,--unresolved-symbols=ignore-all",
"-C", "link-arg=-Wl,--no-as-needed"
]

I then ran cargo build -Z print-link-args and below is the command that rust is using to link the program. Notice the --no-as-needed is added at the end which the linker ignores.

"cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/mauldinl@gvl.is.l-3com.com/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.10imwdy594ztd6bq.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.16d1j1qvoz2m2jvs.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.1fyaisel7xwy8gol.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.1m1fmcgm6riw3k8x.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.1ofvdi3023mvvvco.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.1sxelb0w7h73vp0e.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.26gzaqs5j4288ipr.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.2b1t8ich07w2gvrl.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.2roea1mze8w2afh0.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.3j13xg5n5tgud8iy.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.3sx17r8001u8o3w5.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.4113mge63r7rocsc.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.419w4t766q8u6dci.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.45cnk29n205b6w8p.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.49ob1frj11j54voq.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.4lo6dh84os25q8en.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.4td2c64b2g0tc0pa.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.4ulw9y80xwlyly7h.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.4zvsimlxb9npcpqm.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.9ud5haptujyqskc.rcgu.o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.agcn0tji9vk7e22.rcgu.o" "-o" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps/tclogin-1d2993c5e8dcf6e2.4kzuzfmqupnpce59.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/home/mauldinl@gvl.is.l-3com.com/code/rust/tclogin/target/debug/deps" "-L" "/apps/tc9/lib" "-L" "/apps/tc9/lib/oracle" "-L" "/usr/lib/x86_64-linux-gnu" "-L" "/home/mauldinl@gvl.is.l-3com.com/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lgdis" "-leintstub" "-lnxmgr_im" "-linternal_exits" "-lae" "-laie" "-lappr" "-larchive" "-lvis" "-lvm" "-lbackup" "-lbmf" "-lbob" "-lbom" "-lcae" "-lcfm" "-lconfig" "-lcxpom" "-ldmi" "-lmgc" "-lecm" "-leint" "-lepm" "-lfclasses" "-lform" "-lgrm" "-ltcinit" "-ltc" "-lsml" "-ltccore" "-ltctrushape" "-lqsearch" "-litk" "-lbase_utils" "-lics" "-llov" "-lme" "-lmld" "-lobjio" "-love" "-lproperty" "-lps" "-lpublication" "-lpie" "-lai" "-lqry" "-lres" "-lreq" "-ladsfoundation" "-ltcsoacorestrong" "-lsa" "-lschmgt" "-lschmgt_bridge" "-lss" "-lvispublish" "-lsub_mgr" "-lclientcache" "-ltextsrv" "-lrdv" "-lTcCrypto" "-ltcsso" "-lcollabctx" "-lmechatronics" "-ldocmgtapp" "-lcontmgmt" "-lserver_exits" "-linternal_server_exits" "-ltcgsoap" "-laiwebservice" "-ltcxsd" "-lconfigurator" "-ltcsoacommon" "-ltcsoaclient" "-ltcgateway" "-ltcsoaserver" "-ltcserverutil" "-lvalidation" "-lcp" "-ltcmultisitetypes" "-ltcmultisitestrong" "-ltcsoaworkflow" "-ltcsoaworkflowtypes" "-ltcsoaworkflownative" "-ltc_utils" "-ltccoreext" "-lrbf" "-lce" "-lclips" "-lclipsutil" "-lgms" "-ltie" "-lbriefcase" "-lvisualization" "-lnxclone" "-lvendormanagementdispatch" "-lccdm" "-lproductvariant" "-lfunctionality" "-licsie" "-lcondvalidation" "-lsmartuibldr" "-lfnd0soadiagramming" "-lfnd0soadiagrammingtypes" "-ltcsoacoretypes" "-ltcsoacore" "-ltcsoaprojectmanagement" "-ltcsoaprojectmanagementtypes" "-ltcsoaprojectmanagementnative" "-lbmidebase" "-lpdi_corba_server" "-lict" "-lcba" "-lsharedcache" "-lsharedcachetypes" "-lbooleanmath" "-lcbaext" "-lcfilter" "-lfnd0booleansolve" "-ldispatcher" "-lmeta" "-lmetaframework" "-lsecore" "-lfoundationdispatch" "-lcmdispatch" "-lcm" "-lFnd0nweditor" "-lusagewc" "-lusage" "-lconstants" "-lmfg" "-lmfgbvr" "-lssrsccuaclient" "-lscmccdispatch" "-lextensionframework" "-ldocmgt" "-lissuemgmt" "-lFnd0profiler" "-lFnd0formulamgmt" "-lpom" "-lsyss" "-lugmath" "-lplmxmlSDK" "-lplmxmlExtensions" "-lplmContainerSDK" "-licui18n341" "-lxerces270" "-lxalan110" "-lc" "-lm" "-ldl" "-lnsl" "-lelf" "-lresolv" "-lclntsh" "-ldb2" "-licuuc341" "-licudata341" "-lTcCryptoUtil" "-lpoco" "-lTAO" "-lACE" "-lFnd0propertyrenderer" "-lnnz10" "-ltccurl" "-lTcMemBinding64" "-lTcMemCppBinding64" "-lstdc++" "-Wl,--start-group" "-Wl,-Bstatic" "/home/mauldinl@gvl.is.l-3com.com/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-de5969744423fb69.rlib" "/home/mauldinl@gvl.is.l-3com.com/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-349473e71495321d.rlib" "/home/mauldinl@gvl.is.l-3com.com/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libbacktrace_sys-586a1c8092fef75c.rlib" "/home/mauldinl@gvl.is.l-3com.com/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-132eea50c4719d58.rlib" "/home/mauldinl@gvl.is.l-3com.com/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-ceaa2d4e2e4490ea.rlib" "/home/mauldinl@gvl.is.l-3com.com/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-b0584d127f427a22.rlib" "/home/mauldinl@gvl.is.l-3com.com/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-8570ae25713836c4.rlib" "/home/mauldinl@gvl.is.l-3com.com/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-4ea1c8a0d2fa277d.rlib" "/home/mauldinl@gvl.is.l-3com.com/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-c04ea2c3b5f80e64.rlib" "-Wl,--end-group" "/home/mauldinl@gvl.is.l-3com.com/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-a3371a772297084a.rlib" "-Wl,-Bdynamic" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil" "-Wl,--unresolved-symbols=ignore-all" "-Wl,--no-as-needed"

I need a way to either specify that the RUSTFLAGS should come at the beginning of the command OR a way to explictly inform rust to link to --no-as-needed

Meta

rustc --version --verbose:
rustc 1.33.0-nightly (e2f221c 2019-01-15)
binary: rustc
commit-hash: e2f221c
commit-date: 2019-01-15
host: x86_64-unknown-linux-gnu
release: 1.33.0-nightly
LLVM version: 8.0

OS: Ubuntu 18.04

legokichi, yasuyuky and regen100

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesO-linuxOperating system: LinuxOperating system: Linux

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.