Add support for overriding default compiler flags with '.nim.cfg' and '.nims' configuration files #54
Replies: 3 comments 5 replies
-
|
@SekouDiaoNlp excellent write-up! I think that between all of the available options, the switches.py should be removed since I have seen most people get confused with it and I think for good reason. Originally I had intended that to be easier to use than other methods of overriding the compiler switches but now it just seems to be in the way. Other than that the proposed solution looks fantastic! :) |
Beta Was this translation helpful? Give feedback.
-
|
Hey @Pebaz , what's up? I started implementing the fix for the lto flag on macOS and I am about to write some tests to check if everything is ok. I can test all my changes locally, but as I don't have a mac handy, I use the same workflow file you use to automate testing via GitHub Actions. I wanted to check the logs of your latest builds through Github Actions but the logs have been deleted as they are too old. Could you please re-run some of the latest jobs, so that I can check them out and compare them with mine please?
That would be awesome. Cheers. |
Beta Was this translation helpful? Give feedback.
-
|
See #55 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi @Pebaz and all.
In response to issue #51 regarding the inability to override nimporter's default compiler flags, I have been investigating the issue.
Basically it should be possible to override nimporter's default list of flags
NIM_CLI_ARGSwith values taken from a configuration file other thanswitches.py.According to the nim compiler documentation, the compiler can be configured via both
.nim.cfgand.nimsfiles.One relevant bit of the documentation is:
At the moment
NimCompiler.compile_nim_extension()andNimCompiler.compile_nim_code()don't check if there is a.nim.cfgor.nimsfile in the target directory, and because command-line settings have priority over configuration file settings, once nimporter callsnimbleornimwith it's default flags on the cli, the flags inNIM_CLI_ARGShave priority over any flags the user might have defined in a.nim.cfgor.nims. This means that flags specified outside ofswitches.pyare actually ignored by bothnimbleandnim.Proposed solution:
After a bit of testing with both 'nim_1.5' and 'nim_1.6' it appears that the compiler first checks the presence of a
.nim.cfgfile, and if not found then checks for the presence of a.nimsfile.The solution I propose is to parallel this behaviour. Forward the default cli settings only if no suitable config file has been found, this way the default values in
NIM_CLI_ARGSwon't interfere with user defined flags.Modify
NimCompiler.compile_nim_extension()andNimCompiler.compile_nim_code()to:.nim.cfgfile: If found, don't passNIM_CLI_ARGStonim_args. (new behaviour)..nimsfile: If found, don't passNIM_CLI_ARGStonim_args. (new behaviour)switches.pyfile: If found call get_swiches() and passswitches['bundle']tonim_args. (current behaviour)NIM_CLI_ARGStonim_args. (current behaviour)Let me know if you have any suggestions or comments I should be able to start implementing the changes tomorrow or on Tuesday.
Cheers,
SekouDiaoNlp.
Beta Was this translation helpful? Give feedback.
All reactions