Last active
May 13, 2023 12:21
-
-
Save tothi/1f452e0466070db5921135ab312749fc to your computer and use it in GitHub Desktop.
Nim config script for making Nim build compatible with Mingw-w64 (useful on ArchLinux setups because the defaults there break things)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# original idea: https://github.com/nim-lang/Nim/issues/20007#issue-1300915309 | |
# use case for https://github.com/chvancooten/NimPlant | |
# - put this config.nims into NimPlant/client folder and build should work without errors on ArchLinux also | |
import std/strutils | |
import std/sequtils | |
# remove -fstack-clash-protection | |
switch("gcc.options.always", replace(get("gcc.options.always"), "-fstack-clash-protection", "")) | |
# disable _FORTIFY_SOURCE | |
switch("gcc.options.always", replace(get("gcc.options.always"), "-D_FORTIFY_SOURCE=2", "-D_FORTIFY_SOURCE=0")) | |
proc dropZ(f: string): string = | |
let flags = f.split(",") | |
var result: seq[string] = @[] | |
var drop = false | |
for f in flags: | |
if f == "-z": | |
drop = true | |
elif not drop: | |
result.add(f) | |
else: | |
drop = false | |
return result.join(",") | |
# remove all instance of -z flags and their parameters | |
let new_flags = get("gcc.options.linker").split(" ").map(dropZ).join(" ") | |
switch("gcc.options.linker", new_flags) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment