Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Linker warning recommends a nonexistant gcc::Config.fpic method #33

Closed
Wallacoloo opened this issue Sep 20, 2017 · 2 comments
Closed

Linker warning recommends a nonexistant gcc::Config.fpic method #33

Wallacoloo opened this issue Sep 20, 2017 · 2 comments

Comments

@Wallacoloo
Copy link

When using bindgen + gcc_rs to wrap bare metal C code, gcc_rs defaults to building with -fPIC, even though dynamic relocation never happens, making position independent code nonessential.

At link time when linking to a library built with -fPIC, the cortex-m-rt link script will error with:

.got section detected in the input files. Dynamic relocations are not
supported. If you are linking to C code compiled using the gcc crate
then modify your build script to compile the C code without the
-fPIC flag. See the documentation of the gcc::Config.fpic method for
details.

However, gcc::Config.fpic doesn't appear anywhere in the gcc-rs docs. The solution for me was to use the gcc::Config.flag method, passing it -fno-pic, e.g.

gcc::Build::new().flag("-fno-pic")

I'm not sure if I'm misunderstanding the warning or if it's outdated. If the latter, I tracked the error message down to here & I'm happy to make a PR that updates the message if requested.

@japaric
Copy link
Member

japaric commented Sep 21, 2017

It seems that Config has been renamed to Build in v0.3.51; Config is still around but it's deprecated. In any case, the message in wrong because the method's name is fpic, not pic. That should be fixed.

@japaric
Copy link
Member

japaric commented Jan 17, 2018

the message is wrong because the method's name is fpic, not pic

This has been fixed.

@japaric japaric closed this as completed Jan 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants