Volker Schlecht <openbsd-po...@schlecht.dev> wrote: > I think I got all -O3 replaced by -O2 now. It's still mostly hardcoded > and not picked up from CFLAGS. > > That seems to be intentional: > https://github.com/nim-lang/Nim/issues/3050 > > Also included: > > * your fix for i386 CPU detection > * removed the git call when building nimble > * @sample rename.rules.cfg > * I'm taking the gamble that the > "slow machines can get a head of themselves and fail to link" > comment is not valid anymore, using MAKE_JOBS for the parallelBuild > parameter.
I can't really comment on that. If it was set that way it was for a reason, but IIRC until we add the DPB_PROPERTIES parallel to the port it should still be built with one job on bulk machines, so... (plus i'm happy to see the speed up on my machine!) > How does that work for you? almost there :) The point is not really to blindly use "-O2" instead of "-O3", but to respect the CFLAGS from /etc/mk.conf (which are "-O2 -pipe" by default.) The attached patch does that using SUBST_CMD to set the correct CFLAGS in pre-configure. However this has the consequence (advantage?) that all the executables built with nim will probably inherit the CFLAGS that were set at build time, don't know if it's unwanted or not. There's also the issue that now the "speed" and "size" cflags are actually the same ^^ I've added some comments to the patches, the only thing I don't understand is why comment useFork (I admit I haven't looked into what it does) I've also taken the chance to do some cosmethic changes to the makefile: - drop unused variable VERSION - no need to ${INSTALL_PROGRAM_DIR} ${PREFIX}/bin, it's already there - group some common patterns in a .for loop Thoughts? Index: Makefile =================================================================== RCS file: /home/cvs/ports/lang/nim/Makefile,v retrieving revision 1.11 diff -u -p -r1.11 Makefile --- Makefile 2 May 2020 09:33:06 -0000 1.11 +++ Makefile 27 Feb 2022 23:33:05 -0000 @@ -2,25 +2,24 @@ ONLY_FOR_ARCHS = i386 amd64 -BROKEN-i386 = hardcodes gcc; see config/nim.cfg - COMMENT = statically typed, imperative programming language -VERSION = 1.2.0 -DISTNAME = nim-${VERSION} +DISTNAME = nim-1.6.4 EXTRACT_SUFX = .tar.xz -REVISION = 0 CATEGORIES = lang -HOMEPAGE = http://nim-lang.org/ -MASTER_SITES = http://nim-lang.org/download/ \ - https://download.tuxfamily.org/jod/lang/nim/ +HOMEPAGE = https://nim-lang.org/ +MASTER_SITES = https://nim-lang.org/download/ # MIT PERMIT_PACKAGE = Yes -WANTLIB = c m +WANTLIB = c m pthread + +MODULES = lang/python + +SUBST_VARS += CFLAGS post-patch: mkdir -p ${WRKSRC}/nimcache-port @@ -29,26 +28,30 @@ post-patch: perl -i -pe "s#NIM_PORT_CACHE#${WRKSRC}/nimcache-port-test#" \ ${WRKSRC}/koch.nim +pre-configure: + ${SUBST_CMD} ${WRKSRC}/config/nim.cfg + do-build: cd ${WRKSRC} && ${SETENV} CC="${CC}" LINKER="${CC}" \ + COMP_FLAGS="${CPPFLAGS} ${CFLAGS}" LINK_FLAGS="${LDFLAGS}" \ 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 \ + cd ${WRKSRC} && bin/nim c -d:release --parallelBuild:${MAKE_JOBS} \ --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} && ./koch nimble -d:release --parallelBuild:1 \ +.for t in boot nimble tools + cd ${WRKSRC} && ./koch $t -d:release --parallelBuild:${MAKE_JOBS} \ --nimcache:"${WRKSRC}/nimcache-port" --listFullPaths \ --listCmd --putenv:"PATH=${PATH}" +.endfor do-install: - ${INSTALL_PROGRAM_DIR} ${PREFIX}/bin - ${INSTALL_PROGRAM} ${WRKSRC}/bin/nim ${PREFIX}/bin - ${INSTALL_PROGRAM} ${WRKSRC}/bin/nimble ${PREFIX}/bin +.for b in nim nimble nimpretty nimgrep nimsuggest testament + ${INSTALL_PROGRAM} ${WRKSRC}/bin/$b ${PREFIX}/bin +.endfor ${INSTALL_DATA_DIR} ${PREFIX}/lib/nim cp -R ${WRKSRC}/lib/* ${PREFIX}/lib/nim + ${MODPY_BIN} ${MODPY_LIBDIR}/compileall.py \ + ${PREFIX}/lib/nim/pure/unidecode/gen.py chown -R ${LIBOWN}:${LIBGRP} ${PREFIX}/lib/nim ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/nim ${INSTALL_DATA} ${WRKSRC}/doc/*.txt ${PREFIX}/share/doc/nim Index: distinfo =================================================================== RCS file: /home/cvs/ports/lang/nim/distinfo,v retrieving revision 1.5 diff -u -p -r1.5 distinfo --- distinfo 2 May 2020 09:33:06 -0000 1.5 +++ distinfo 27 Feb 2022 22:57:13 -0000 @@ -1,2 +1,2 @@ -SHA256 (nim-1.2.0.tar.xz) = TpRYOjc5ZYIYBeZl4KBfUvthCRZnbtsJFIlBQVY3xXU= -SIZE (nim-1.2.0.tar.xz) = 5869428 +SHA256 (nim-1.6.4.tar.xz) = f8MJKFW1wiAM2f7tEz0EYFgj8lDXO01KxQEwA3DgoMI= +SIZE (nim-1.6.4.tar.xz) = 5130208 Index: patches/patch-build_sh =================================================================== RCS file: patches/patch-build_sh diff -N patches/patch-build_sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-build_sh 27 Feb 2022 23:54:40 -0000 @@ -0,0 +1,26 @@ +$OpenBSD$ + + - don't hardcode -O3 + - fix wrong usage of test(1) + +Index: build.sh +--- build.sh.orig ++++ build.sh +@@ -60,7 +60,7 @@ if [ "$parallel" -gt 1 ]; then + fi + CC="sem -j $parallel --id $$ ${CC}" + fi +-COMP_FLAGS="${CPPFLAGS:-} ${CFLAGS:-} -w -fmax-errors=3 -O3 -fno-strict-aliasing -fno-ident $extraBuildArgs" ++COMP_FLAGS="${CPPFLAGS:-} ${CFLAGS:-} -w -fmax-errors=3 -fno-strict-aliasing -fno-ident $extraBuildArgs" + LINK_FLAGS="${LDFLAGS:-} " + PS4="" + # platform detection +@@ -163,7 +163,7 @@ esac + + case $ucpu in + *i386* | *i486* | *i586* | *i686* | *bepc* | *i86pc* ) +- if [ isOpenIndiana -eq "yes" ] ; then ++ if [ isOpenIndiana == "yes" ] ; then + mycpu="amd64" + else + mycpu="i386" Index: patches/patch-config_nim_cfg =================================================================== RCS file: /home/cvs/ports/lang/nim/patches/patch-config_nim_cfg,v retrieving revision 1.4 diff -u -p -r1.4 patch-config_nim_cfg --- patches/patch-config_nim_cfg 2 May 2020 09:33:06 -0000 1.4 +++ patches/patch-config_nim_cfg 27 Feb 2022 23:54:21 -0000 @@ -1,6 +1,11 @@ $OpenBSD: patch-config_nim_cfg,v 1.4 2020/05/02 09:33:06 denis Exp $ ---- config/nim.cfg.orig Sun Jan 8 21:33:42 2017 -+++ config/nim.cfg Mon Jan 9 02:28:32 2017 + + - use clang + - don't hardcode -O3 and respect ${CFLAGS} + +Index: config/nim.cfg +--- config/nim.cfg.orig ++++ config/nim.cfg @@ -8,7 +8,7 @@ # Environment variables can be accessed like so: # gcc.path %= "$CC_PATH" @@ -10,16 +15,43 @@ $OpenBSD: patch-config_nim_cfg,v 1.4 202 # additional options always passed to the compiler: --parallel_build: "0" # 0 to auto-detect number of processors -@@ -118,12 +118,6 @@ path="$lib/pure" - clang.options.linker = "-ldl" - clang.cpp.options.linker = "-ldl" - tcc.options.linker = "-ldl" -- @end -- @if bsd: -- # BSD got posix_spawn only recently, so we deactivate it for osproc: +@@ -111,7 +111,7 @@ nimblepath="$home/.nimble/pkgs/" + @if unix: + @if bsd: + # BSD got posix_spawn only recently, so we deactivate it for osproc: - define:useFork -- # at least NetBSD has problems with thread local storage: -- tlsEmulation:on - @end - @if haiku: ++ # define:useFork + @elif haiku: gcc.options.linker = "-Wl,--as-needed -lnetwork" + gcc.cpp.options.linker = "-Wl,--as-needed -lnetwork" +@@ -229,15 +229,15 @@ 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 + +-gcc.options.speed = "-O3 -fno-strict-aliasing -fno-ident" +-gcc.options.size = "-Os -fno-ident" ++gcc.options.speed = "${CFLAGS} -fno-strict-aliasing -fno-ident" ++gcc.options.size = "${CFLAGS} -fno-ident" + @if windows: + gcc.options.debug = "-g3 -Og -gdwarf-3" + @else: + gcc.options.debug = "-g3 -Og" + @end +-gcc.cpp.options.speed = "-O3 -fno-strict-aliasing -fno-ident" +-gcc.cpp.options.size = "-Os -fno-ident" ++gcc.cpp.options.speed = "${CFLAGS} -fno-strict-aliasing -fno-ident" ++gcc.cpp.options.size = "${CFLAGS} -fno-ident" + gcc.cpp.options.debug = "-g3 -Og" + #passl = "-pg" + +@@ -251,8 +251,8 @@ llvm_gcc.options.size = "-Os" + clang.options.debug = "-g" + clang.cpp.options.debug = "-g" + clang.options.always = "-w -ferror-limit=3" +-clang.options.speed = "-O3" +-clang.options.size = "-Os" ++clang.options.speed = "${CFLAGS}" ++clang.options.size = "${CFLAGS}" + + @if windows: + clang_cl.cpp.options.always %= "${clang_cl.options.always} /EHsc" Index: patches/patch-dist_nimble_src_nimblepkg_options_nim =================================================================== RCS file: patches/patch-dist_nimble_src_nimblepkg_options_nim diff -N patches/patch-dist_nimble_src_nimblepkg_options_nim --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-dist_nimble_src_nimblepkg_options_nim 27 Feb 2022 23:53:39 -0000 @@ -0,0 +1,20 @@ +$OpenBSD$ + +don't exec git + +Index: dist/nimble/src/nimblepkg/options.nim +--- dist/nimble/src/nimblepkg/options.nim.orig ++++ dist/nimble/src/nimblepkg/options.nim +@@ -161,12 +161,6 @@ proc writeHelp*(quit=true) = + proc writeVersion*() = + echo("nimble v$# compiled at $# $#" % + [nimbleVersion, CompileDate, CompileTime]) +- const execResult = gorgeEx("git rev-parse HEAD") +- when execResult[0].len > 0 and execResult[1] == QuitSuccess: +- echo "git hash: ", execResult[0] +- else: +- {.warning: "Couldn't determine GIT hash: " & execResult[0].} +- echo "git hash: couldn't determine git hash" + raise NimbleQuit(msg: "") + + proc parseActionType*(action: string): ActionType = Index: patches/patch-install_sh =================================================================== RCS file: patches/patch-install_sh diff -N patches/patch-install_sh --- patches/patch-install_sh 2 May 2020 09:33:06 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,70 +0,0 @@ ---- install.sh.orig 2020-04-03 17:25:49 UTC -+++ install.sh -@@ -15,48 +15,14 @@ if [ $# -eq 1 ] ; then - "--help"|"-h"|"help"|"h") - echo "Nim installation script" - echo "Usage: [sudo] sh install.sh DIR" -- echo "Where DIR may be:" -- echo " /usr/bin" -- echo " /usr/local/bin" -- echo " /opt" -- echo " <some other dir> (treated similar to '/opt')" -- echo "To deinstall, use the command:" -- echo "sh deinstall.sh DIR" - exit 1 - ;; -- "/usr/bin") -- bindir=/usr/bin -- configdir=/etc/nim -- libdir=/usr/lib/nim -- docdir=/usr/share/nim/doc -- datadir=/usr/share/nim/data -- nimbleDir="/opt/nimble/pkgs/compiler-1.2.0" -- ;; -- "/usr/local/bin") -- bindir=/usr/local/bin -- configdir=/etc/nim -- libdir=/usr/local/lib/nim -- docdir=/usr/local/share/nim/doc -- datadir=/usr/local/share/nim/data -- nimbleDir="/opt/nimble/pkgs/compiler-1.2.0" -- ;; -- "/opt") -- bindir="/opt/nim/bin" -- configdir="/opt/nim/config" -- libdir="/opt/nim/lib" -- docdir="/opt/nim/doc" -- datadir="/opt/nim/data" -- nimbleDir="/opt/nimble/pkgs/compiler-1.2.0" -- mkdir -p /opt/nim -- mkdir -p $bindir -- mkdir -p $configdir -- ;; - *) -- bindir="$1/nim/bin" -- configdir="$1/nim/config" -- libdir="$1/nim/lib" -- docdir="$1/nim/doc" -- datadir="$1/nim/data" -+ bindir="$1/bin" -+ configdir="$1/etc/nim" -+ libdir="$1/lib" -+ docdir="$1/share/doc/nim" -+ datadir="$1/share/nim" - nimbleDir="$1/nim" - mkdir -p $1/nim - mkdir -p $bindir -@@ -973,13 +939,6 @@ chmod 644 $nimbleDir/compiler.nimble - else - echo "Nim installation script" - echo "Usage: [sudo] sh install.sh DIR" -- echo "Where DIR may be:" -- echo " /usr/bin" -- echo " /usr/local/bin" -- echo " /opt" -- echo " <some other dir> (treated similar to '/opt')" -- echo "To deinstall, use the command:" -- echo "sh deinstall.sh DIR" - exit 1 - fi - Index: pkg/PLIST =================================================================== RCS file: /home/cvs/ports/lang/nim/pkg/PLIST,v retrieving revision 1.5 diff -u -p -r1.5 PLIST --- pkg/PLIST 2 May 2020 09:33:06 -0000 1.5 +++ pkg/PLIST 27 Feb 2022 22:57:13 -0000 @@ -4,6 +4,10 @@ @sample ${SYSCONFDIR}/nim/ @bin bin/nim @bin bin/nimble +@bin bin/nimgrep +@bin bin/nimpretty +@bin bin/nimsuggest +@bin bin/testament lib/nim/ lib/nim/arch/ lib/nim/arch/x86/ @@ -25,6 +29,7 @@ lib/nim/deprecated/pure/ospaths.nim lib/nim/deprecated/pure/parseopt2.nim lib/nim/deprecated/pure/securehash.nim lib/nim/deprecated/pure/sharedstrings.nim +lib/nim/deps.txt lib/nim/experimental/ lib/nim/experimental/diff.nim lib/nim/genode/ @@ -47,19 +52,19 @@ lib/nim/impure/re.nim lib/nim/js/ lib/nim/js/asyncjs.nim lib/nim/js/dom.nim +lib/nim/js/dom_extensions.nim lib/nim/js/jsconsole.nim lib/nim/js/jscore.nim lib/nim/js/jsffi.nim +lib/nim/js/jsre.nim lib/nim/nimbase.h lib/nim/nimhcr.nim lib/nim/nimhcr.nim.cfg lib/nim/nimrtl.nim lib/nim/nimrtl.nim.cfg -lib/nim/nintendoswitch/ -lib/nim/nintendoswitch/switch_memory.nim lib/nim/packages/ lib/nim/packages/docutils/ -lib/nim/packages/docutils/docutils.nimble +lib/nim/packages/docutils/docutils.nimble.old lib/nim/packages/docutils/highlite.nim lib/nim/packages/docutils/rst.nim lib/nim/packages/docutils/rstast.nim @@ -70,6 +75,8 @@ lib/nim/posix/inotify.nim lib/nim/posix/kqueue.nim lib/nim/posix/linux.nim lib/nim/posix/posix.nim +lib/nim/posix/posix_freertos_consts.nim +lib/nim/posix/posix_haiku.nim lib/nim/posix/posix_linux_amd64.nim lib/nim/posix/posix_linux_amd64_consts.nim lib/nim/posix/posix_macos_amd64.nim @@ -80,7 +87,6 @@ lib/nim/posix/posix_other.nim lib/nim/posix/posix_other_consts.nim lib/nim/posix/posix_utils.nim lib/nim/posix/termios.nim -lib/nim/prelude.nim lib/nim/pure/ lib/nim/pure/algorithm.nim lib/nim/pure/async.nim @@ -176,6 +182,7 @@ lib/nim/pure/parseutils.nim lib/nim/pure/parsexml.nim lib/nim/pure/pathnorm.nim lib/nim/pure/pegs.nim +lib/nim/pure/prelude.nim lib/nim/pure/punycode.nim lib/nim/pure/random.nim lib/nim/pure/rationals.nim @@ -186,8 +193,10 @@ lib/nim/pure/selectors.nim lib/nim/pure/smtp.nim lib/nim/pure/smtp.nim.cfg lib/nim/pure/ssl_certs.nim +lib/nim/pure/ssl_config.nim lib/nim/pure/stats.nim lib/nim/pure/streams.nim +lib/nim/pure/streamwrapper.nim lib/nim/pure/strformat.nim lib/nim/pure/strmisc.nim lib/nim/pure/strscans.nim @@ -199,6 +208,8 @@ lib/nim/pure/times.nim lib/nim/pure/typetraits.nim lib/nim/pure/unicode.nim lib/nim/pure/unidecode/ +${MODPY_COMMENT}lib/nim/pure/unidecode/${MODPY_PYCACHE}/ +lib/nim/pure/unidecode/${MODPY_PYCACHE}gen.${MODPY_PYC_MAGIC_TAG}pyc lib/nim/pure/unidecode/gen.py lib/nim/pure/unidecode/unidecode.dat lib/nim/pure/unidecode/unidecode.nim @@ -211,15 +222,47 @@ lib/nim/std/ lib/nim/std/compilesettings.nim lib/nim/std/decls.nim lib/nim/std/editdistance.nim +lib/nim/std/effecttraits.nim +lib/nim/std/enumerate.nim +lib/nim/std/enumutils.nim +lib/nim/std/exitprocs.nim +lib/nim/std/genasts.nim +lib/nim/std/importutils.nim +lib/nim/std/isolation.nim +lib/nim/std/jsbigints.nim +lib/nim/std/jsfetch.nim +lib/nim/std/jsformdata.nim +lib/nim/std/jsheaders.nim +lib/nim/std/jsonutils.nim lib/nim/std/logic.nim lib/nim/std/monotimes.nim +lib/nim/std/packedsets.nim lib/nim/std/private/ +lib/nim/std/private/asciitables.nim +lib/nim/std/private/bitops_utils.nim +lib/nim/std/private/dbutils.nim +lib/nim/std/private/decode_helpers.nim +lib/nim/std/private/digitsutils.nim +lib/nim/std/private/gitutils.nim +lib/nim/std/private/globs.nim +lib/nim/std/private/jsutils.nim +lib/nim/std/private/miscdollars.nim +lib/nim/std/private/since.nim +lib/nim/std/private/strimpl.nim lib/nim/std/private/underscored_calls.nim +lib/nim/std/private/win_setenv.nim +lib/nim/std/setutils.nim lib/nim/std/sha1.nim +lib/nim/std/socketstreams.nim lib/nim/std/stackframes.nim +lib/nim/std/strbasics.nim lib/nim/std/sums.nim +lib/nim/std/sysrand.nim +lib/nim/std/tasks.nim +lib/nim/std/tempfiles.nim lib/nim/std/time_t.nim lib/nim/std/varints.nim +lib/nim/std/vmutils.nim lib/nim/std/with.nim lib/nim/std/wordwrap.nim lib/nim/std/wrapnils.nim @@ -228,6 +271,7 @@ lib/nim/system/ lib/nim/system.nim lib/nim/system/alloc.nim lib/nim/system/ansi_c.nim +lib/nim/system/arc.nim lib/nim/system/arithm.nim lib/nim/system/arithmetics.nim lib/nim/system/assertions.nim @@ -235,15 +279,20 @@ lib/nim/system/assign.nim lib/nim/system/atomics.nim lib/nim/system/avltree.nim lib/nim/system/basic_types.nim +lib/nim/system/bitmasks.nim +lib/nim/system/cellseqs_v1.nim +lib/nim/system/cellseqs_v2.nim lib/nim/system/cellsets.nim lib/nim/system/cgprocs.nim -lib/nim/system/channels.nim +lib/nim/system/channels_builtin.nim lib/nim/system/chcks.nim lib/nim/system/comparisons.nim +lib/nim/system/coro_detection.nim +lib/nim/system/countbits_impl.nim lib/nim/system/cyclebreaker.nim -lib/nim/system/cyclicrefs_v2.nim lib/nim/system/deepcopy.nim lib/nim/system/dollars.nim +lib/nim/system/dragonbox.nim lib/nim/system/dyncalls.nim lib/nim/system/embedded.nim lib/nim/system/exceptions.nim @@ -275,16 +324,20 @@ lib/nim/system/mm/malloc.nim lib/nim/system/mm/none.nim lib/nim/system/mmdisp.nim lib/nim/system/nimscript.nim +lib/nim/system/orc.nim lib/nim/system/osalloc.nim lib/nim/system/platforms.nim lib/nim/system/profiler.nim -lib/nim/system/refs_v2.nim lib/nim/system/repr.nim +lib/nim/system/repr_impl.nim lib/nim/system/repr_v2.nim lib/nim/system/reprjs.nim +lib/nim/system/schubfach.nim lib/nim/system/seqs_v2.nim +lib/nim/system/seqs_v2_reimpl.nim lib/nim/system/setops.nim lib/nim/system/sets.nim +lib/nim/system/stacktraces.nim lib/nim/system/strmantle.nim lib/nim/system/strs_v2.nim lib/nim/system/syslocks.nim @@ -299,7 +352,6 @@ lib/nim/windows/ lib/nim/windows/registry.nim lib/nim/windows/winlean.nim lib/nim/wrappers/ -lib/nim/wrappers/iup.nim lib/nim/wrappers/linenoise/ lib/nim/wrappers/linenoise/LICENSE.txt lib/nim/wrappers/linenoise/README.markdown @@ -321,6 +373,7 @@ share/doc/nim/effects.txt share/doc/nim/filelist.txt share/doc/nim/grammar.txt share/doc/nim/keywords.txt +share/doc/nim/nimgrep_cmdline.txt share/doc/nim/pegdocs.txt share/doc/nim/readme.txt share/doc/nim/regexprs.txt @@ -334,3 +387,5 @@ share/examples/nim/nimdoc.cfg @sample ${SYSCONFDIR}/nim/nimdoc.cfg share/examples/nim/nimdoc.tex.cfg @sample ${SYSCONFDIR}/nim/nimdoc.tex.cfg +share/examples/nim/rename.rules.cfg +@sample ${SYSCONFDIR}/nim/rename.rules.cfg