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

Support compiling different files with different options #545

Open
joshtriplett opened this issue Aug 15, 2020 · 4 comments
Open

Support compiling different files with different options #545

joshtriplett opened this issue Aug 15, 2020 · 4 comments

Comments

@joshtriplett
Copy link
Member

I'd like to have better support for compiling different files with different compiler options. For instance, I'd like to compile avx2-foo.c with -mavx2, without applying that flag to any other source file.

@alexcrichton
Copy link
Member

I think this can be done with separate instances of Build?

@joshtriplett
Copy link
Member Author

The problem is that each Build builds a separate library archive, and combining archives requires quite a bit of non-portable platform-specific knowledge. The ideal behavior would be to compile different object files with different options, then combine those objects into one archive.

It might work to use a separate Build for different sets of options, so that you could add common options, clone the Build, add different options, and add the files that use those options. But then there would need to be a way to re-combine the Build instances to link a single library at the end. Perhaps Build could have a function that takes ownership of another Build, and the Build can have a list of owned sub-builds?

@alexcrichton
Copy link
Member

But you don't need to combine archives? They're just both passed to the linker?

@joshtriplett
Copy link
Member Author

joshtriplett commented Aug 24, 2020

@alexcrichton You do when you're building a library that other crates want to find by name, such as if you're constructing a static library and associated pkg-config files and headers to put on the search path.

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