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

Unable to inject build option (e.g. -fPIC) on Linux #2

Closed
paniq opened this issue Jan 11, 2015 · 4 comments
Closed

Unable to inject build option (e.g. -fPIC) on Linux #2

paniq opened this issue Jan 11, 2015 · 4 comments

Comments

@paniq
Copy link

paniq commented Jan 11, 2015

I need to build NFD as part of a shared object on Linux, which makes it necessary to build libnfd.a with the -fPIC option; For Makefile-, CMake- or Premake-based projects, I usually just set CFLAGS/CXXFLAGS in the environment, and that propagates to the Makefile. However, SCons seems to ignore environment variables.

Is there a possibility to build the library with -fPIC or other manual build options without patching SConstruct?

@mlabbe
Copy link
Owner

mlabbe commented Jan 11, 2015

Scons doesn't permit environment variables to override its internal environment by default. However, I can see why that would be useful as a vendor providing a library to a third party.

I have a fix which I'm in the process of testing on my array of build servers now. I am exposing the following:

'CC', 'CXX', 'CFLAGS', 'CXXFLAGS', 'ARFLAGS'

@paniq
Copy link
Author

paniq commented Jan 11, 2015

that sounds pretty good!

@mlabbe
Copy link
Owner

mlabbe commented Jan 11, 2015

Okay, I pushed the improvement after testing in 5 build environments. I think having the ability to set these values from the command line is useful, but I don't think it gets you all the way to a shared lib. We've been talking on Twitter, but for the sake of others who come across this, there are a couple of challenges related to getting NFD compiling as a shared library.

As far as Scons is concerened, turning the nfd_env.StaticLibrary() call into nfd_env.SharedLibrary() should do the trick.

As you mentioned, the free() call would fail on Windows, as DLLs do not share heap space.

If someone wants to take the plunge and do a full .so patch, I would take a good look at merging that!

@paniq
Copy link
Author

paniq commented Jan 11, 2015

Thanks :)

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