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

File-specific compilation flags #12662

Closed
mratsim opened this issue Nov 14, 2019 · 3 comments
Closed

File-specific compilation flags #12662

mratsim opened this issue Nov 14, 2019 · 3 comments

Comments

@mratsim
Copy link
Collaborator

mratsim commented Nov 14, 2019

As mentioned a long time ago on IRC and here #11202 (comment) file-specific compilation flags would be useful.

Currently I have to maintain a complex cfg and/or nimble files with variations for Windows/Mac/Linux + making sure that the compiler doesn't compile a SSE2 file with AVX2 otherwise the SSE2 platform will not get SSE2 SIMD.

https://github.com/numforge/laser/blob/3c3c6f526d877cb8fdb7c8bf6e0f0867259e6a42/nim.cfg#L18-L37
https://github.com/mratsim/Arraymancer/blob/master/arraymancer.nimble#L40-L81

This would be useful for:

I'm not alone in needing this:

@Araq I couldn't find the last discussion (April) where you said that it was planned for the future, so tracking here so that it's not forgotten.

@slomp
Copy link

slomp commented Nov 14, 2019

Related: idea for push/pop pragmas to work with passC pragmas et al.:
https://irclogs.nim-lang.org/09-10-2018.html#21:19:24

@timotheecour
Copy link
Member

one example use case among many: it would allow compiling different nim files with different modes, eg: nim c, nim cpp, nim objc and linking all them together. In particular it would simplify #12653 (comment) by compiling the objective C code inside nimextras_objc (as an emit statement inside a nim program) as nim objc so there wouldn't be a separate compilation step needed for that nimextras_objc.mm.

@slomp
Copy link

slomp commented Nov 27, 2019

it would allow compiling different nim files with different modes, eg: nim c, nim cpp, nim objc and linking all them together.

Hi @timotheecour
Would you mind elaborating a bit more on that?
Suppose I have a set of .c files, a set of .cpp files, and a set of .mm files, and that I have some nim files (say, cfiles.nim, cppfiles.nim and mmfiles.nim) that call the appropriate compile/pass pragmas. How do you tell nim to generate objects out of each of them and then subsequently link those objects together into an executable?
( I know this Issue is closed, but I'm really curious :) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants