summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorEuan <euantorano@users.noreply.github.com>2020-06-16 07:50:57 +0100
committerGitHub <noreply@github.com>2020-06-16 08:50:57 +0200
commit7b12f13946e833d85ddfe23fafee0c808b27bafb (patch)
tree7f9db52e41788ec20ff9d6e4cd054fbabeabd90b
parentde5cde473a2809ac4a2940ec2704d575307521b4 (diff)
downloadNim-7b12f13946e833d85ddfe23fafee0c808b27bafb.tar.gz
Use cc on OpenBSD and link to libm when building result (#14672)
-rw-r--r--tools/detect/detect.nim21
1 files changed, 16 insertions, 5 deletions
diff --git a/tools/detect/detect.nim b/tools/detect/detect.nim
index 720e24975..a10794555 100644
--- a/tools/detect/detect.nim
+++ b/tools/detect/detect.nim
@@ -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
@@ -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: