On Wed, Mar 01, 2017 at 11:36:52PM +0100, Juan Francisco Cantero Hurtado wrote:
> On Wed, Mar 01, 2017 at 11:09:03PM +0100, Christian Weisgerber wrote:
> > Juan Francisco Cantero Hurtado:
> >
> > > They have a simple option to change the compilers but we need a variable
> > > with the realname of the compiler, i.e. clang or gcc.
> > >
> > > You can use "nim c -cc:clang" or "nim c -cc:gcc" (the default) or "nim c
> > > -cc:egcc". All of them are the name of the profile, not the compiler
> > > executable.
> > >
> > > Here is the patch. It includes some adittional changes. If someone has
> > > an better idea for the conditional... I'm listening :)
> >
> > CLANG_ARCHS was added incompletely, so you need arch-defines.mk
> > r1.32 for that:
> >
> > .include <bsd.port.arch.mk>
> >
> > # CC is always "cc". We need the real name.
> > .if ${PROPERTIES:Mclang}
> > CC = clang
> > .else
> > CC = gcc
> > .endif
> >
> > BTW, I think using CC for a variable with different semantics is a
> > bad idea. Pick a different name, please.
>
> Thanks. How about "COMPILER" or "C_COMP"?
I changed the variable to NIM_CC. OK?
Index: Makefile
===================================================================
RCS file: /cvs/ports/lang/nim/Makefile,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile
--- Makefile 9 Jan 2017 10:32:33 -0000 1.6
+++ Makefile 1 Mar 2017 23:41:07 -0000
@@ -5,6 +5,7 @@ ONLY_FOR_ARCHS = i386 amd64
COMMENT = statically typed, imperative programming language
VERSION = 0.16.0
+REVISION = 0
DISTNAME = nim-${VERSION}
EXTRACT_SUFX = .tar.xz
@@ -19,23 +20,28 @@ PERMIT_PACKAGE_CDROM = Yes
WANTLIB = c m
+SUBST_VARS += NIM_CC
+
post-patch:
mkdir -p ${WRKSRC}/nimcache-port
mkdir -p ${WRKSRC}/nimcache-port-test
perl -i -pe "s#NIM_PORT_PATH#${PATH}#" ${WRKSRC}/koch.nim
perl -i -pe "s#NIM_PORT_CACHE#${WRKSRC}/nimcache-port-test#" \
${WRKSRC}/koch.nim
+ ${SUBST_CMD} ${WRKSRC}/koch.nim ${WRKSRC}/tests/testament/tester.nim \
+ ${WRKSRC}/config/nim.cfg
do-build:
- cd ${WRKSRC} && ${SETENV} CC="${CC}" LINKER="${CC}" \
+ cd ${WRKSRC} && ${SETENV} CC="${NIM_CC}" LINKER="${NIM_CC}" \
CFLAGS="${CFLAGS}" sh build.sh
# slow machines can get a head of themselves and fail to link
- cd ${WRKSRC} && bin/nim c -d:release --parallelBuild:1 \
- --nimcache:"${WRKSRC}/nimcache-port" --listFullPaths \
- --listCmd --putenv:"PATH=${PATH}" koch
- cd ${WRKSRC} && ./koch boot -d:release --parallelBuild:1 \
- --nimcache:"${WRKSRC}/nimcache-port" --listFullPaths \
- --listCmd --putenv:"PATH=${PATH}"
+ cd ${WRKSRC} && bin/nim c -d:release --cc:${NIM_CC} --parallelBuild:1 \
+ --nimcache:"${WRKSRC}/nimcache-port" --listFullPaths --listCmd \
+ --putenv:"PATH=${PATH} CC=${NIM_CC} LINKER=${NIM_CC}" \
+ koch
+ cd ${WRKSRC} && ./koch boot -d:release --cc:${NIM_CC} --parallelBuild:1
\
+ --nimcache:"${WRKSRC}/nimcache-port" --listFullPaths --listCmd \
+ --putenv:"PATH=${PATH} CC=${NIM_CC} LINKER=${NIM_CC}"
do-install:
${INSTALL_PROGRAM_DIR} ${PREFIX}/bin
@@ -49,9 +55,17 @@ do-install:
${INSTALL_DATA} ${WRKSRC}/config/*.cfg ${PREFIX}/share/examples/nim
do-test:
- cd ${WRKSRC} && ${SETENV} ./koch test all -d:release \
- --parallelBuild:1 --listFullPaths --listCmd \
- --nimcache:"${WRKSRC}/nimcache-port-test" \
- --putenv:"PATH=${PATH}"
+ cd ${WRKSRC} && ${SETENV} ./koch test all -d:release --threads:on \
+ --cc:${NIM_CC} --parallelBuild:1 --listFullPaths --listCmd \
+ --passL:"-pthread
-Wl,-rpath=.:/usr/local/lib:${WRKSRC}/nimcache-port-test/" \
+ --putenv:"PATH=${PATH} CC=${NIM_CC} LINKER=${NIM_CC}"
+
+.include <bsd.port.arch.mk>
+
+.if ${PROPERTIES:Mclang}
+NIM_CC = clang
+.elif
+NIM_CC = gcc
+.endif
.include <bsd.port.mk>
Index: patches/patch-config_nim_cfg
===================================================================
RCS file: /cvs/ports/lang/nim/patches/patch-config_nim_cfg,v
retrieving revision 1.3
diff -u -p -r1.3 patch-config_nim_cfg
--- patches/patch-config_nim_cfg 9 Jan 2017 10:32:33 -0000 1.3
+++ patches/patch-config_nim_cfg 1 Mar 2017 23:41:07 -0000
@@ -1,6 +1,15 @@
$OpenBSD: patch-config_nim_cfg,v 1.3 2017/01/09 10:32:33 juanfra Exp $
--- config/nim.cfg.orig Sun Jan 8 21:33:42 2017
-+++ config/nim.cfg Mon Jan 9 02:28:32 2017
++++ config/nim.cfg Wed Mar 1 00:00:37 2017
+@@ -8,7 +8,7 @@
+ # Environment variables can be accessed like so:
+ # gcc.path %= "$CC_PATH"
+
+-cc = gcc
++cc = ${NIM_CC}
+
+ # additional options always passed to the compiler:
+ --parallel_build: "0" # 0 to auto-detect number of processors
@@ -76,7 +76,7 @@ path="$lib/pure"
@end
@if bsd or haiku:
@@ -19,7 +28,16 @@ $OpenBSD: patch-config_nim_cfg,v 1.3 201
@end
# Configuration for Objective-C compiler:
-@@ -155,18 +157,23 @@ clang.objc.options.linker = "-lobjc -lgnustep-base"
+@@ -135,6 +137,8 @@ clang.objc.options.linker = "-lobjc -lgnustep-base"
+ @if freebsd or openbsd or netbsd:
+ gcc.options.linker =
"-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
+ gcc.cpp.options.linker =
"-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
++ egcc.options.linker =
"-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
++ egcc.cpp.options.linker =
"-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
+ llvm_gcc.options.linker =
"-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
+ llvm_gcc.cpp.options.linker =
"-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
+ clang.options.linker =
"-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
+@@ -155,18 +159,23 @@ clang.objc.options.linker = "-lobjc -lgnustep-base"
gcc.options.linker %= "-L $WIND_BASE/target/lib/usr/lib/ppc/PPC32/common
-mrtp -fno-strict-aliasing -D_C99 -D_HAS_C9X -std=c99 -fasm -Wall
-Wno-write-strings"
@end
@@ -45,7 +63,7 @@ $OpenBSD: patch-config_nim_cfg,v 1.3 201
# Configuration for the LLVM GCC compiler:
llvm_gcc.options.debug = "-g"
llvm_gcc.options.always = "-w"
-@@ -176,7 +183,7 @@ llvm_gcc.options.size = "-Os"
+@@ -176,7 +185,7 @@ llvm_gcc.options.size = "-Os"
# Configuration for the LLVM CLang compiler:
clang.options.debug = "-g"
clang.options.always = "-w"
Index: patches/patch-koch_nim
===================================================================
RCS file: /cvs/ports/lang/nim/patches/patch-koch_nim,v
retrieving revision 1.2
diff -u -p -r1.2 patch-koch_nim
--- patches/patch-koch_nim 9 Jan 2017 10:32:33 -0000 1.2
+++ patches/patch-koch_nim 1 Mar 2017 23:41:07 -0000
@@ -1,12 +1,19 @@
$OpenBSD: patch-koch_nim,v 1.2 2017/01/09 10:32:33 juanfra Exp $
--- koch.nim.orig Sun Jan 8 21:33:42 2017
-+++ koch.nim Mon Jan 9 03:15:50 2017
-@@ -393,7 +393,7 @@ proc tests(args: string) =
- nimexec "cc --taintMode:on tests/testament/tester"
++++ koch.nim Tue Feb 28 23:20:42 2017
+@@ -390,12 +390,12 @@ template `|`(a, b): string = (if a.len > 0: a else: b)
+ proc tests(args: string) =
+ # we compile the tester with taintMode:on to have a basic
+ # taint mode test :-)
+- nimexec "cc --taintMode:on tests/testament/tester"
++ nimexec "cc --taintMode:on --cc:${NIM_CC} tests/testament/tester"
# Since tests take a long time (on my machine), and we want to defy Murhpys
# law - lets make sure the compiler really is freshly compiled!
- nimexec "c --lib:lib -d:release --opt:speed compiler/nim.nim"
-+ nimexec "c --lib:lib -d:release --opt:speed --listFullPaths --listCmd
--putenv:PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin::
--nimcache:/usr/write-ports/pobj/nim-0.16.0/nim-0.16.0/nimcache-port-test
compiler/nim.nim"
++ nimexec "c --lib:lib -d:release --cc:${NIM_CC} --opt:speed --listFullPaths
--listCmd
--putenv:PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin::
--nimcache:/usr/write-ports/pobj/nim-0.16.0/nim-0.16.0/nimcache-port-test
compiler/nim.nim"
let tester = quoteShell(getCurrentDir() / "tests/testament/tester".exe)
- let success = tryExec tester & " " & (args|"all")
+- let success = tryExec tester & " " & (args|"all")
++ let success = tryExec tester & " --targets:c " & " " & (args|"all")
if not existsEnv("TRAVIS") and not existsEnv("APPVEYOR"):
+ exec tester & " html"
+ if not success:
Index: patches/patch-tests_testament_tester_nim
===================================================================
RCS file: /cvs/ports/lang/nim/patches/patch-tests_testament_tester_nim,v
retrieving revision 1.3
diff -u -p -r1.3 patch-tests_testament_tester_nim
--- patches/patch-tests_testament_tester_nim 9 Jan 2017 10:32:33 -0000
1.3
+++ patches/patch-tests_testament_tester_nim 1 Mar 2017 23:41:07 -0000
@@ -8,7 +8,7 @@ FAILURE
Error 1 in . (Makefile:42 'do-test')"
--- tests/testament/tester.nim.orig Sun Jan 8 21:33:43 2017
-+++ tests/testament/tester.nim Mon Jan 9 02:33:36 2017
++++ tests/testament/tester.nim Tue Feb 28 23:20:42 2017
@@ -12,7 +12,7 @@
import
parseutils, strutils, pegs, os, osproc, streams, parsecfg, json,
@@ -18,6 +18,15 @@ Error 1 in . (Makefile:42 'do-test')"
const
resultsFile = "testresults.html"
+@@ -118,7 +118,7 @@ proc callCCompiler(cmdTemplate, filename, options: str
+ target: TTarget): TSpec =
+ let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
+ "options", options, "file", filename.quoteShell])
+- var p = startProcess(command="gcc", args=c[5.. ^1],
++ var p = startProcess(command="${NIM_CC}", args=c[5.. ^1],
+ options={poStdErrToStdOut, poUsePath})
+ let outp = p.outputStream
+ var x = newStringOfCap(120)
@@ -326,7 +326,7 @@ proc testSpec(r: var TResults, test: TTest) =
r.addResult(test, expected.outp, "executable not found", reExeNotFound)
return