Skip to content

Commit

Permalink
Use cc on OpenBSD and link to libm when building result (#14672)
Browse files Browse the repository at this point in the history
  • Loading branch information
euantorano authored Jun 16, 2020
1 parent de5cde4 commit 7b12f13
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions tools/detect/detect.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@
# compilation.
import os, strutils

const
cc = "gcc -o $# $#.c"
cpp = "gcc -E -o $#.i $#.c"
when defined(openbsd):
const
cc = "cc -o $# $#.c"
cpp = "cc -E -o $#.i $#.c"
ccLinkMath = "cc -lm -o $# $#.c"
cppLinkMath = "cc -lm -E -o $#.i $#.c"
else:
const
cc = "gcc -o $# $#.c"
cpp = "gcc -E -o $#.i $#.c"

const
cfile = """
/* Generated by detect.nim */
#define _GNU_SOURCE
Expand Down Expand Up @@ -89,8 +97,11 @@ proc main =
if open(f, "other_consts.nim", fmWrite):
f.write(nimfile % [other])
close(f)
if not myExec(cc % [gen.addFileExt(ExeExt), gen]): quit(1)
if not myExec(cpp % [pre.addFileExt(ExeExt), pre]): quit(1)

let cCompile = when defined(openbsd): ccLinkMath else: cc
let cppCompile = when defined(openbsd): cppLinkMath else: cpp
if not myExec(cCompile % [gen.addFileExt(ExeExt), gen]): quit(1)
if not myExec(cppCompile % [pre.addFileExt(ExeExt), pre]): quit(1)
when defined(windows):
if not myExec(gen.addFileExt(ExeExt)): quit(1)
else:
Expand Down

0 comments on commit 7b12f13

Please sign in to comment.