Skip to content

Commit d0485e3

Browse files
authored
bring back std/ prefix within compiler and ensure it works in bootstrap + bsd (#17902)
* [WIP] bring back std/ prefix within compiler and ensure it works in bootstrap + bsd * refs #16282 (comment) * sounds very similar to #14291 * more: vmops * update tools/ci_generate.nim * auto-generate freebsd.yml as well, to avoid duplication with openbsd.yml * cleanup * undo temporary CI removal
1 parent d32ab61 commit d0485e3

File tree

7 files changed

+65
-33
lines changed

7 files changed

+65
-33
lines changed

.builds/freebsd.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## DO NO EDIT DIRECTLY! auto-generated by `nim r tools/ci_generate.nim`
2+
13
# see https://man.sr.ht/builds.sr.ht/compatibility.md#freebsd
24
image: freebsd/latest
35
packages:
@@ -8,9 +10,12 @@ packages:
810
- devel/sfml
911
- www/node
1012
- devel/gmake
13+
14+
1115
sources:
1216
- https://github.com/nim-lang/Nim
1317
environment:
18+
NIM_TESTAMENT_BATCH: "0_1"
1419
CC: /usr/bin/clang
1520
tasks:
1621
- setup: |
@@ -20,9 +25,10 @@ tasks:
2025
$nim_csources c --skipUserCfg --skipParentCfg koch
2126
echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv
2227
- test: |
28+
set -e
2329
cd Nim
2430
if ! ./koch runCI; then
25-
nim c -r tools/ci_testresults.nim
31+
nim r tools/ci_testresults.nim
2632
exit 1
2733
fi
2834
triggers:

.builds/openbsd_0.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## do not edit directly; auto-generated by `nim r tools/ci_generate.nim`
1+
## DO NO EDIT DIRECTLY! auto-generated by `nim r tools/ci_generate.nim`
22

33
image: openbsd/latest
44
packages:
@@ -10,6 +10,8 @@ packages:
1010
- sfml
1111
- sdl2
1212
- libffi
13+
14+
1315
sources:
1416
- https://github.com/nim-lang/Nim
1517
environment:
@@ -20,9 +22,10 @@ tasks:
2022
set -e
2123
cd Nim
2224
. ci/funs.sh && nimBuildCsourcesIfNeeded
23-
$nim_csources c koch
25+
$nim_csources c --skipUserCfg --skipParentCfg koch
2426
echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv
2527
- test: |
28+
set -e
2629
cd Nim
2730
if ! ./koch runCI; then
2831
nim r tools/ci_testresults.nim

.builds/openbsd_1.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## do not edit directly; auto-generated by `nim r tools/ci_generate.nim`
1+
## DO NO EDIT DIRECTLY! auto-generated by `nim r tools/ci_generate.nim`
22

33
image: openbsd/latest
44
packages:
@@ -10,6 +10,8 @@ packages:
1010
- sfml
1111
- sdl2
1212
- libffi
13+
14+
1315
sources:
1416
- https://github.com/nim-lang/Nim
1517
environment:
@@ -20,9 +22,10 @@ tasks:
2022
set -e
2123
cd Nim
2224
. ci/funs.sh && nimBuildCsourcesIfNeeded
23-
$nim_csources c koch
25+
$nim_csources c --skipUserCfg --skipParentCfg koch
2426
echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv
2527
- test: |
28+
set -e
2629
cd Nim
2730
if ! ./koch runCI; then
2831
nim r tools/ci_testresults.nim

compiler/ic/dce.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
## Dead code elimination (=DCE) for IC.
1111

12-
import intsets, tables
12+
import std/[intsets, tables]
1313
import ".." / [ast, options, lineinfos, types]
1414

1515
import packed_ast, ic, bitabs

compiler/vmops.nim

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@
99

1010
# Unfortunately this cannot be a module yet:
1111
#import vmdeps, vm
12-
from math import sqrt, ln, log10, log2, exp, round, arccos, arcsin,
12+
from std/math import sqrt, ln, log10, log2, exp, round, arccos, arcsin,
1313
arctan, arctan2, cos, cosh, hypot, sinh, sin, tan, tanh, pow, trunc,
1414
floor, ceil, `mod`, cbrt, arcsinh, arccosh, arctanh, erf, erfc, gamma,
1515
lgamma
1616

1717
when declared(math.copySign):
18-
from math import copySign
18+
from std/math import copySign
1919

2020
when declared(math.signbit):
21-
from math import signbit
21+
from std/math import signbit
2222

23-
from os import getEnv, existsEnv, dirExists, fileExists, putEnv, walkDir,
23+
from std/os import getEnv, existsEnv, dirExists, fileExists, putEnv, walkDir,
2424
getAppFilename, raiseOSError, osLastError
2525

26-
from md5 import getMD5
27-
from times import cpuTime
28-
from hashes import hash
29-
from osproc import nil
26+
from std/md5 import getMD5
27+
from std/times import cpuTime
28+
from std/hashes import hash
29+
from std/osproc import nil
3030

3131
from sighashes import symBodyDigest
3232

koch.nim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,9 @@ proc runCI(cmd: string) =
534534
echo "runCI: ", cmd
535535
echo hostInfo()
536536
# boot without -d:nimHasLibFFI to make sure this still works
537-
kochExecFold("Boot in release mode", "boot -d:release -d:nimStrictMode")
537+
# `--lib:lib` is needed for bootstrap on openbsd, for reasons described in
538+
# https://github.com/nim-lang/Nim/pull/14291 (`getAppFilename` bugsfor older nim on openbsd).
539+
kochExecFold("Boot in release mode", "boot -d:release -d:nimStrictMode --lib:lib")
538540

539541
when false: # debugging: when you need to run only 1 test in CI, use something like this:
540542
execFold("debugging test", "nim r tests/stdlib/tosproc.nim")

tools/ci_generate.nim

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
##[
22
avoid code duplication in CI pipelines.
3-
For now, this is only used for openbsd, but there is a lot of other code
3+
For now, this is only used for openbsd + freebsd, but there is a lot of other code
44
duplication that could be removed.
55
66
## usage
@@ -10,22 +10,14 @@ nim r tools/ci_generate.nim
1010
```
1111
]##
1212

13-
import std/strformat
13+
import std/[strformat, os]
1414

15-
proc genCIopenbsd(batch: int, num: int): string =
15+
proc genCiBsd(header: string, batch: int, num: int): string =
1616
result = fmt"""
17-
## do not edit directly; auto-generated by `nim r tools/ci_generate.nim`
17+
## DO NO EDIT DIRECTLY! auto-generated by `nim r tools/ci_generate.nim`
18+
19+
{header}
1820
19-
image: openbsd/latest
20-
packages:
21-
- gmake
22-
- sqlite3
23-
- node
24-
- boehm-gc
25-
- pcre
26-
- sfml
27-
- sdl2
28-
- libffi
2921
sources:
3022
- https://github.com/nim-lang/Nim
3123
environment:
@@ -36,9 +28,10 @@ tasks:
3628
set -e
3729
cd Nim
3830
. ci/funs.sh && nimBuildCsourcesIfNeeded
39-
$nim_csources c koch
31+
$nim_csources c --skipUserCfg --skipParentCfg koch
4032
echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv
4133
- test: |
34+
set -e
4235
cd Nim
4336
if ! ./koch runCI; then
4437
nim r tools/ci_testresults.nim
@@ -51,14 +44,39 @@ triggers:
5144
"""
5245

5346
proc main()=
47+
let dir = ".builds"
5448
# not too large to be resource friendly, refs bug #17107
5549
let num = 2
5650
# if you reduce this, make sure to remove files that shouldn't be generated,
5751
# or better, do the cleanup logic here e.g.: `rm .builds/openbsd_*`
52+
let headerFreebsd = """
53+
# see https://man.sr.ht/builds.sr.ht/compatibility.md#freebsd
54+
image: freebsd/latest
55+
packages:
56+
- databases/sqlite3
57+
- devel/boehm-gc-threaded
58+
- devel/pcre
59+
- devel/sdl20
60+
- devel/sfml
61+
- www/node
62+
- devel/gmake
63+
"""
64+
65+
let headerOpenbsd = """
66+
image: openbsd/latest
67+
packages:
68+
- gmake
69+
- sqlite3
70+
- node
71+
- boehm-gc
72+
- pcre
73+
- sfml
74+
- sdl2
75+
- libffi
76+
"""
5877
for i in 0..<num:
59-
let file = fmt".builds/openbsd_{i}.yml"
60-
let code = genCIopenbsd(i, num)
61-
writeFile(file, code)
78+
writeFile(dir / fmt"openbsd_{i}.yml", genCiBsd(headerOpenbsd, i, num))
79+
writeFile(dir / "freebsd.yml", genCiBsd(headerFreebsd, 0, 1))
6280

6381
when isMainModule:
6482
main()

0 commit comments

Comments
 (0)