Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Apple Silicon / M1 #16211

Closed
kolinko opened this issue Dec 1, 2020 · 28 comments
Closed

Support for Apple Silicon / M1 #16211

kolinko opened this issue Dec 1, 2020 · 28 comments

Comments

@kolinko
Copy link

kolinko commented Dec 1, 2020

./build.sh seems to fail on M1, I managed to compile it by hacking the file, but I'm not sure if it's a proper solution.

Example

./build.sh

Current Output

% ./build.sh 
# OS: macosx
# CPU: arm64
clang -o bin/nim -ldl -lm
Undefined symbols for architecture arm64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Possible Solution

I switched amd64 to arm64 in the line 6640 of ./build.sh.

It just compiled and it seems to be running well on my laptop. I don't know enough about makefiles and build scripts to make a proper pull request though.

@timotheecour
Copy link
Member

timotheecour commented Dec 1, 2020

  • can you try: sh build_all.sh ?

I don't know enough about makefiles and build scripts to make a proper pull request though.

can you please give it a try? not many people will have M1 macs so your help is appreciated

a few things are need:

  • add support for M1 in CI (ideally each CI pipeline, eg azure, github)
  • brew itself is playing catch up to support M1 and CI depends on brew in some parts; adjustments may be needed there

@kolinko
Copy link
Author

kolinko commented Dec 2, 2020

Calling build_all.sh gives this:

kolinko@MacBook-Pro Nim % ./build_all.sh
build_nim_csources
/usr/bin/make
make -C csources -j 10 -l 8
makefile:156: *** unknown processor: arm64.  Stop.
cd csources
sh build.sh
# OS: macosx
# CPU: arm
clang -o ../bin/nim -ldl -lm
Undefined symbols for architecture arm64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

But it works smoothly after modyfing the following lines.

Do I just do a pull request with the changes to the Makefile? I'm not too familiar with all the CI stuff :)

Lines 152-154 in Makefile:

ifeq ($(ucpu),arm64)
  mycpu = arm64
endif

And then, lines 305-307 in Makefile: (copied from amd64)

  ifeq ($(mycpu),arm64)
    oFiles = c_code/1_2/stdlib_assertions.nim.o c_code/1_2/stdlib_dollars.nim.o c_code/3_2/stdlib_io.nim.o c_code/3_2/stdlib_system.nim.o c_code/2_2/stdlib_parseutils.nim.o c_code/2_2/stdlib_math.nim.o c_code/1_2/stdlib_algorithm.nim.o c_code/2_2/stdlib_unicode.nim.o c_code/2_2/stdlib_strutils.nim.o c_code/2_2/stdlib_pathnorm.nim.o c_code/3_2/stdlib_posix.nim.o c_code/3_2/stdlib_times.nim.o c_code/3_2/stdlib_os.nim.o c_code/1_2/stdlib_hashes.nim.o c_code/1_2/stdlib_strtabs.nim.o c_code/3_2/stdlib_streams.nim.o c_code/3_2/stdlib_cpuinfo.nim.o c_code/3_2/stdlib_osproc.nim.o c_code/1_2/stdlib_sets.nim.o c_code/2_2/pathutils.nim.o c_code/1_2/ropes.nim.o c_code/1_2/stdlib_tables.nim.o c_code/1_2/lineinfos.nim.o c_code/3_2/platform.nim.o c_code/1_2/prefixmatches.nim.o c_code/2_2/stdlib_strformat.nim.o c_code/2_2/stdlib_terminal.nim.o c_code/3_2/options.nim.o c_code/3_2/msgs.nim.o c_code/1_2/wordrecg.nim.o c_code/1_2/idents.nim.o c_code/1_2/condsyms.nim.o c_code/1_2/stdlib_sha1.nim.o c_code/2_2/stdlib_lexbase.nim.o c_code/1_2/stdlib_parsejson.nim.o c_code/3_2/stdlib_json.nim.o c_code/3_2/extccomp.nim.o c_code/3_2/nimblecmd.nim.o c_code/2_2/stdlib_parseopt.nim.o c_code/3_2/commands.nim.o c_code/1_2/llstream.nim.o c_code/1_2/nimlexbase.nim.o c_code/3_2/lexer.nim.o c_code/2_2/nimconf.nim.o c_code/1_2/stdlib_intsets.nim.o c_code/1_2/idgen.nim.o c_code/1_2/ast.nim.o c_code/1_2/rodutils.nim.o c_code/2_2/astalgo.nim.o c_code/1_2/parser.nim.o c_code/1_2/renderer.nim.o c_code/1_2/filters.nim.o c_code/1_2/filter__tmpl.nim.o c_code/1_2/syntaxes.nim.o c_code/1_2/trees.nim.o c_code/3_2/types.nim.o c_code/1_2/treetab.nim.o c_code/1_2/incremental.nim.o c_code/1_2/btrees.nim.o c_code/1_2/stdlib_md5.nim.o c_code/1_2/modulegraphs.nim.o c_code/1_2/magicsys.nim.o c_code/1_2/bitsets.nim.o c_code/1_2/nimsets.nim.o c_code/3_2/semfold.nim.o c_code/3_2/modulepaths.nim.o c_code/1_2/reorder.nim.o c_code/1_2/passes.nim.o c_code/1_2/vmdef.nim.o c_code/1_2/semdata.nim.o c_code/1_2/linter.nim.o c_code/1_2/nimfix7prettybase.nim.o c_code/1_2/lookups.nim.o c_code/1_2/semtypinst.nim.o c_code/1_2/parampatterns.nim.o c_code/1_2/lowerings.nim.o c_code/1_2/_7lib7packages7docutils7rstast.nim.o c_code/1_2/_7lib7packages7docutils7rst.nim.o c_code/1_2/_7lib7packages7docutils7highlite.nim.o c_code/3_2/_7lib7packages7docutils7rstgen.nim.o c_code/1_2/stdlib_xmltree.nim.o c_code/1_2/stdlib_uri.nim.o c_code/1_2/stdlib_cgi.nim.o c_code/1_2/typesrenderer.nim.o c_code/2_2/docgen.nim.o c_code/3_2/sigmatch.nim.o c_code/1_2/importer.nim.o c_code/1_2/procfind.nim.o c_code/3_2/pragmas.nim.o c_code/1_2/saturate.nim.o c_code/1_2/guards.nim.o c_code/1_2/sighashes.nim.o c_code/1_2/sempass2.nim.o c_code/1_2/cgmeth.nim.o c_code/1_2/aliases.nim.o c_code/1_2/patterns.nim.o c_code/1_2/dfa.nim.o c_code/1_2/injectdestructors.nim.o c_code/1_2/liftlocals.nim.o c_code/1_2/lambdalifting.nim.o c_code/1_2/closureiters.nim.o c_code/1_2/transf.nim.o c_code/1_2/vmgen.nim.o c_code/3_2/vmdeps.nim.o c_code/1_2/vmmarshal.nim.o c_code/3_2/gorgeimpl.nim.o c_code/1_2/macrocacheimpl.nim.o c_code/1_2/evaltempl.nim.o c_code/3_2/vm.nim.o c_code/1_2/semmacrosanity.nim.o c_code/1_2/pluginsupport.nim.o c_code/1_2/plugins7locals.nim.o c_code/1_2/plugins7itersgen.nim.o c_code/1_2/plugins7active.nim.o c_code/1_2/semparallel.nim.o c_code/3_2/sem.nim.o c_code/1_2/ccgutils.nim.o c_code/1_2/ndi.nim.o c_code/1_2/cgendata.nim.o c_code/1_2/ccgmerge.nim.o c_code/1_2/enumtostr.nim.o c_code/2_2/stdlib_dynlib.nim.o c_code/1_2/cgen.nim.o c_code/1_2/passaux.nim.o c_code/1_2/depends.nim.o c_code/1_2/modules.nim.o c_code/1_2/jsgen.nim.o c_code/3_2/docgen2.nim.o c_code/1_2/main.nim.o c_code/3_2/scriptconfig.nim.o c_code/3_2/cmdlinehelper.nim.o c_code/3_2/nim.nim.o
  endif

@kolinko
Copy link
Author

kolinko commented Dec 2, 2020

I prepared a change to the Makefile in the csources repo, but I can't initiate a pull request because that repo is archived/read-only.

https://github.com/nim-lang/csources/compare/master...kolinko:patch-1?expand=1

@kolinko
Copy link
Author

kolinko commented Dec 2, 2020

I ran koch tests, and there are some failed ones. I'm not sure if this is normal.

FAILURE! total: 118 passed: 98 skipped: 0 failed: 20
FAIL: tests/parallel/tconvexhull.nim c
Test "tests/parallel/tconvexhull.nim" in category "parallel"
Failure: reNimcCrash
$ bin/nim c --hints:on -d:testing --nimblePath:tests/deps --nimCache:nimcache/tests/parallel/tconvexhull.nim_4a8a08f09d37b73795649038408b5f33 tests/parallel/tconvexhull.nim
Hint: used config file '/Users/kolinko/Downloads/nim/Nim/config/nim.cfg' [Conf]
Hint: used config file '/Users/kolinko/Downloads/nim/Nim/config/config.nims' [Conf]
Hint: used config file '/Users/kolinko/Downloads/nim/Nim/tests/config.nims' [Conf]
Hint: used config file '/Users/kolinko/Downloads/nim/Nim/tests/parallel/nim.cfg' [Conf]
........................CC: stdlib_threadpool.nim
/Users/kolinko/Downloads/nim/Nim/nimcache/tests/parallel/tconvexhull.nim_4a8a08f09d37b73795649038408b5f33/stdlib_threadpool.nim.c:831:15: error: unrecognized instruction mnemonic
        asm volatile("pause" ::: "memory");
                     ^
<inline asm>:1:2: note: instantiated into assembly here
        pause
        ^
1 error generated.

Error: execution of an external compiler program 'clang -c  -w -ferror-limit=3 -pthread   -I/Users/kolinko/Downloads/nim/Nim/lib -I/Users/kolinko/Downloads/nim/Nim/tests/parallel -o /Users/kolinko/Downloads/nim/Nim/nimcache/tests/parallel/tconvexhull.nim_4a8a08f09d37b73795649038408b5f33/stdlib_threadpool.nim.c.o /Users/kolinko/Downloads/nim/Nim/nimcache/tests/parallel/tconvexhull.nim_4a8a08f09d37b73795649038408b5f33/stdlib_threadpool.nim.c' failed with exit code: 1
FAIL: tests/osproc/treadlines.nim c
Test "tests/osproc/treadlines.nim" in category "osproc"
Failure: reExitcodesDiffer
Expected:
exitcode: 0

Gotten:
exitcode: 1

Output:
treadlines.nim(12)       treadlines
osproc.nim(990)          startProcess
osproc.nim(1068)         startProcessAuxSpawn
oserr.nim(94)            raiseOSError
Error: unhandled exception: No such file or directory
Additional info: "nim" [OSError]
FAIL: tests/dll/nimhcr_unit.nim c  --passL:-rpath --passL:@loader_path
Test "tests/dll/nimhcr_unit.nim" in category "dll"
Failure: reExitcodesDiffer
Expected:
exitcode: 0

Gotten:
exitcode: 1

Output:
nimhcr_unit.nim(109)     nimhcr_unit
/Users/kolinko/Downloads/nim/Nim/lib/nimhcr.nim(346) hcrRegisterProc
/Users/kolinko/Downloads/nim/Nim/lib/pure/reservedmem.nim(223) setLen
/Users/kolinko/Downloads/nim/Nim/lib/pure/reservedmem.nim(97) setLen
/Users/kolinko/Downloads/nim/Nim/lib/pure/includes/oserr.nim(94) raiseOSError
Error: unhandled exception: Permission denied [OSError]
FAIL: tests/range/tcompiletime_range_checks.nim c
Test "tests/range/tcompiletime_range_checks.nim" in category "range"
Failure: reMsgsDiffer
Expected:
tcompiletime_range_checks.nim(36, 21) Error: 2147483648 can't be converted to int32
tcompiletime_range_checks.nim(37, 23) Error: -1 can't be converted to uint64
tcompiletime_range_checks.nim(38, 34) Error: 255 can't be converted to FullNegativeRange
tcompiletime_range_checks.nim(39, 34) Error: 18446744073709551615 can't be converted to HalfNegativeRange
tcompiletime_range_checks.nim(40, 34) Error: 300 can't be converted to FullPositiveRange
tcompiletime_range_checks.nim(41, 30) Error: 101 can't be converted to UnsignedRange
tcompiletime_range_checks.nim(42, 32) Error: -9223372036854775808 can't be converted to SemiOutOfBounds
tcompiletime_range_checks.nim(44, 22) Error: nan can't be converted to int32
tcompiletime_range_checks.nim(46, 23) Error: 1e+100 can't be converted to uint64
tcompiletime_range_checks.nim(49, 22) Error: 18446744073709551615 can't be converted to int64
tcompiletime_range_checks.nim(50, 22) Error: 18446744073709551615 can't be converted to int32
tcompiletime_range_checks.nim(51, 22) Error: 18446744073709551615 can't be converted to int16
tcompiletime_range_checks.nim(52, 21) Error: 18446744073709551615 can't be converted to int8
  

Gotten:
tcompiletime_range_checks.nim(36, 21) Error: 2147483648 can't be converted to int32
tcompiletime_range_checks.nim(37, 23) Error: -1 can't be converted to uint64
tcompiletime_range_checks.nim(38, 34) Error: 255 can't be converted to FullNegativeRange
tcompiletime_range_checks.nim(39, 34) Error: 18446744073709551615 can't be converted to HalfNegativeRange
tcompiletime_range_checks.nim(40, 34) Error: 300 can't be converted to FullPositiveRange
tcompiletime_range_checks.nim(41, 30) Error: 101 can't be converted to UnsignedRange
tcompiletime_range_checks.nim(42, 32) Error: -9223372036854775808 can't be converted to SemiOutOfBounds
tcompiletime_range_checks.nim(44, 22) Error: nan can't be converted to int32
tcompiletime_range_checks.nim(49, 22) Error: 18446744073709551615 can't be converted to int64
tcompiletime_range_checks.nim(50, 22) Error: 18446744073709551615 can't be converted to int32
tcompiletime_range_checks.nim(51, 22) Error: 18446744073709551615 can't be converted to int16
tcompiletime_range_checks.nim(52, 21) Error: 18446744073709551615 can't be converted to int8
FAIL: tests/dll/nimhcr_unit.nim c  -d:release --passL:-rpath --passL:@loader_path
Test "tests/dll/nimhcr_unit.nim" in category "dll"
Failure: reExitcodesDiffer
Expected:
exitcode: 0

Gotten:
exitcode: 1

Output:
oserr.nim(94)            raiseOSError
Error: unhandled exception: Permission denied [OSError]
FAIL: tests/stdlib/tosproc.nim c
Test "tests/stdlib/tosproc.nim" in category "stdlib"
Failure: reExitcodesDiffer
Expected:
exitcode: 0

Gotten:
exitcode: 1

Output:
(arg2: "exit_0", expected2: 0)
(msg: "child binary", pid: 57837)
(arg: "exit_0")
(arg2: "exitnow_139", expected2: 139)
(msg: "child binary", pid: 57856)
(arg: "exitnow_139")
(arg2: "c_exit2_139", expected2: 139)
(msg: "child binary", pid: 57857)
(arg: "c_exit2_139")
(arg2: "quit_139", expected2: 139)
(msg: "child binary", pid: 57858)
(arg: "quit_139")
tosproc.nim(217)         tosproc
assertions.nim(30)       failedAssertImpl
assertions.nim(23)       raiseAssert
fatal.nim(49)            sysFatal
Error: unhandled exception: tosproc.nim(217, 14) `result == ("12\n", 0)`  [AssertionDefect]
FAIL: megatest compilation failed
FAIL: tests/niminaction/Chapter8/sfml/sfml_test.nim cpp  --nilseqs:on
Test "tests/niminaction/Chapter8/sfml/sfml_test.nim" in category "niminaction"
Failure: reNimcCrash
$ bin/nim cpp --hints:on -d:testing --nimblePath:tests/deps --nilseqs:on --nimCache:nimcache/tests/niminaction/Chapter8/sfml/sfml_test.nim_6305fdad6890ee3469841b946211b108 --stdout '--hint[Path]:off' '--hint[Processing]:off' tests/niminaction/Chapter8/sfml/sfml_test.nim
Hint: used config file '/Users/kolinko/Downloads/nim/Nim/config/nim.cfg' [Conf]
Hint: used config file '/Users/kolinko/Downloads/nim/Nim/config/config.nims' [Conf]
Hint: used config file '/Users/kolinko/Downloads/nim/Nim/tests/config.nims' [Conf]
CC: sfml_test.nim
/Users/kolinko/Downloads/nim/Nim/nimcache/tests/niminaction/Chapter8/sfml/sfml_test.nim_6305fdad6890ee3469841b946211b108/@msfml_test.nim.cpp:10:10: fatal error: 'SFML/Graphics.hpp' file not found
#include <SFML/Graphics.hpp>
         ^~~~~~~~~~~~~~~~~~~
1 error generated.
Error: execution of an external compiler program 'clang++ -c -std=gnu++14 -funsigned-char    -I/Users/kolinko/Downloads/nim/Nim/lib -I/Users/kolinko/Downloads/nim/Nim/tests/niminaction/Chapter8/sfml -o /Users/kolinko/Downloads/nim/Nim/nimcache/tests/niminaction/Chapter8/sfml/sfml_test.nim_6305fdad6890ee3469841b946211b108/@msfml_test.nim.cpp.o /Users/kolinko/Downloads/nim/Nim/nimcache/tests/niminaction/Chapter8/sfml/sfml_test.nim_6305fdad6890ee3469841b946211b108/@msfml_test.nim.cpp' failed with exit code: 1
FAIL: tests/stdlib/tunittest_error.nim js
Test "tests/stdlib/tunittest_error.nim" in category "stdlib"
Failure: reOutputsDiffer
Expected:
failed: 1 == 3

Gotten:
/Users/kolinko/Downloads/nim/Nim/tests/stdlib/tunittest_error.js:3163
if (globalThis.utcInstance_838863012 === undefined) {
^

ReferenceError: globalThis is not defined
    at Object.<anonymous> (/Users/kolinko/Downloads/nim/Nim/tests/stdlib/tunittest_error.js:3163:1)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3

FAIL: tests/gc/cyclecollector c  --gc:boehm
Test "tests/gc/cyclecollector" in category "gc"
Failure: reExitcodesDiffer
Expected:
exitcode: 0

Gotten:
exitcode: 1

Output:
could not load: libgc.dylib
(compile with -d:nimDebugDlOpen for more information)

@timotheecour
Copy link
Member

timotheecour commented Dec 2, 2020

I prepared a change to the Makefile in the csources repo, but I can't initiate a pull request because that repo is archived/read-only.

csources.Makefile is auto-generated; instead the fix should go in compiler/installer.ini, maybe:

macosx: i386;amd64;powerpc64
=>
macosx: i386;amd64;powerpc64;arm64

when csources is finally updated (not loosing hope), it'll then pick up this change.

I ran koch tests, and there are some failed ones. I'm not sure if this is normal.

I would've been surprised if it worked out of the box; just like for any platform, not everything has to work from day 1, this is a start (we can turn this issue into a meta-issue tracking M1, like #14075 for freebsd)

EDIT

#11457 (comment)

As I said, once the time comes, we'll simply have a csources2 repo and all the scripts out there continue to give you Nim version 1.0 or whatever people did setup.

maybe with M1, the time has come for csources2 (and revive/redo #13854), and bootstrap from latest stable (1.4.2) ?

@dom96
Copy link
Contributor

dom96 commented Dec 2, 2020

csources.Makefile is auto-generated; instead the fix should go in compiler/installer.ini, maybe:

Yep, that's all that should be needed to get it going.

It most definitely works, the C Sources just don't get built for arm64 on macOS (since that wasn't a thing in the past). But Nim has been working fine on arm for years.

@kolinko
Copy link
Author

kolinko commented Dec 3, 2020

Tried it, changing installer.ini, nor makefile.nimf, doesn't work.

build_all.sh fetches csources from repo, and just calls csources/build.sh as it is, with no auto-generation.

There is also no way to change build_all to regenerate csources/build.sh, because regenerating from template requires koch or niminstall, and those are yet to be built at that stage.

The only easy solution that comes to my mind, without updating the csources repo, would be to modify build_all.sh to patch build.sh if it notices MacOS&arm64 architecture. A bit hackish, but would allow people to build for M1 until csources2 arrives.

@timotheecour
Copy link
Member

nim c koch then ./koch -h shows:

csource -d:danger        builds the C sources for installation

maybe try ./koch csource ?

@kolinko
Copy link
Author

kolinko commented Dec 3, 2020

Yes, but build_all.sh doesn't do this, because nim and koch are not yet built at that stage.

build_all.sh uses Makefile as it is in csources repo. The only way is to either change the Makefile, or change build_all.sh to patch Makefile. We cannot add ./koch csource to build_all.sh.

@Araq
Copy link
Member

Araq commented Dec 3, 2020

We're preparing a csources2 repo based on Nim version 1, stay tuned.

@timotheecour
Copy link
Member

timotheecour commented Dec 3, 2020

We're preparing a csources2 repo based on Nim version 1, stay tuned.

@Araq great to finally hear that, but can we please have an RFC so people can chime in? I can write it if needed.

  • I would like csources2 to be built from latest stable (1.4.2) (as opposed to 1.0.0 or 1.0.8) to allow nim compiler/koch/bootstrapping to benefit from all recent improvements; nim --useVersion:1.0 can in particular still continue to work and be tested for. The bump 0.20.0 => 1.0 is otherwise underwhelming.
  • the commit hash from which nim is bootstrapped must be checked in git repo, to avoid the same mistake as was done for csources (helps with tooling in particular for git bisect which needs to know how to build nim from any version)

@Araq
Copy link
Member

Araq commented Dec 3, 2020

The bump 0.20.0 => 1.0 is otherwise underwhelming.

Why? What do we want to use in the Nim compiler that is not in version 1.0? Note that every stdlib addition can directly be used within the Nim compiler as only the v1.0 nim binary is used for bootstrapping.

@dom96
Copy link
Contributor

dom96 commented Dec 3, 2020

If you implement this then the next Nim release will be built for arm64 on Mac OS. The C Sources for devel builds might still be broken sure, but you'll just be able to use the newest released Nim version instead.

@timotheecour
Copy link
Member

timotheecour commented Dec 3, 2020

@Araq

What do we want to use in the Nim compiler that is not in version 1.0?

Every single compiler (non-stdlib) improvement (bugfix, feature, new cmdline flags) since 1.0, which is a lot.
1.0 is just a number, not a gold standard, and we can still ensure nim --useVersion:1.0 works.

Nim kept bootstrapping from previous stable at regular intervals in the past (v0.20.0 v0.19.0 v0.18.0 v0.17.2 v0.16.0 v0.15.2 v0.13.0 v0.9.4, see https://github.com/timotheecour/csources/tags) which allowed compiler to benefit from latest stable release improvements and cleanup code, there's no reason why this should stop just because 1.0 was released.

All those conditionals in condsyms.nim add up and prevent cleanups, eg run this snippet timotheecour#389 (comment) to get the number of occurrences of each defined symbol in condsyms, it gives you a breakdown per symbol;

  • the grand total is 76 defined symbol in condsyms and 276 total occurrences. That's not negligible. The ones since 1.0.0 would be a subset of those.

  • cleanups like those from nimHasCastPragmaBlocks to allow using cast[nosideeffects]

  • cleanups like nimToOpenArrayCString (appears a lot)
    etc

Beyond compiler sources, I'd also like koch (+ all the files it depends on, kochdocs etc) to benefit from recent compiler features; this also helps with promoting more recent best practices.

I'm curious what are the downsides you have in mind for bootstrapping from latest stable and updating csources2 as was the case until recently. I'm not aware of people ever complaining about that (apart from not knowing which nim is needed for bootstrapping, which is easily fixed, eg as I did in #13854).

If you still disagree, then how about opening an RFC to discuss that.

@Araq
Copy link
Member

Araq commented Dec 3, 2020

Every single compiler (non-stdlib) improvement (bugfix, feature, new cmdline flags) since 1.0, which is a lot.

That's not an answer, that is avoiding an answer. Which language features past 1.0 are useful inside the Nim compiler? Again, library additions don't count, we can use pretty much all of them.

1.0 is just a number, not a gold standard, and we can still ensure nim --useVersion:1.0 works.

1.0 is not just a number, it's our long-term stable release. And currently our only one. It makes sense to demand that a Nim version 1.0 compiler can compile later Nim compilers.

there's no reason why this should stop just because 1.0 was released.

I remember the times we updated the csources frequently, I'm not looking back. The current way is much more pleasant to work with.

Beyond compiler sources, I'd also like koch (+ all the files it depends on, kochdocs etc) to benefit from recent compiler features; this also helps with promoting more recent best practices.

Like what? Which features would these be that are helpful for koch?

All those conditionals in condsyms.nim add up and prevent cleanups

These cleanups should be done for Nim version 2 IMHO.

@awr1
Copy link
Contributor

awr1 commented Dec 7, 2020

We're preparing a csources2 repo based on Nim version 1, stay tuned.

Should be called something like "csources-v1" to reduce confusion IMO. But this is good news!

This was referenced Dec 7, 2020
@ghost
Copy link

ghost commented Dec 20, 2020

Is csources_v1 still being worked on? The last commit seems to be two weeks old, and hacking the build_all.sh to git install it instead of csources isn’t sufficient to build on my M1.

@Araq
Copy link
Member

Araq commented Dec 21, 2020

Yes. Please try again, I cannot test it as I don't have an M1.

@jivank
Copy link

jivank commented Dec 26, 2020

I am getting the same error as mentioned here:
nim-lang/csources_v1#1

@ghost
Copy link

ghost commented Jan 20, 2021

I switched amd64 to arm64 in the line 6640 of ./build.sh.

It just compiled and it seems to be running well on my laptop. I don't know enough about makefiles and build scripts to make a proper pull request though

This solution from the OG seems to work on older commits not using build_all

@Araq
Copy link
Member

Araq commented Jan 21, 2021

csources_v1 now works on the M1 to the best of my knowledge. (Tested it myself manually.)

@Araq Araq closed this as completed Jan 21, 2021
@ghost
Copy link

ghost commented Jan 21, 2021

Maybe I'm doing something wrong?

MBP:Desktop$git clone https://github.com/nim-lang/Nim
Cloning into 'Nim'...
remote: Enumerating objects: 400, done.
remote: Counting objects: 100% (400/400), done.
remote: Compressing objects: 100% (77/77), done.
remote: Total 134902 (delta 333), reused 363 (delta 323), pack-reused 134502
Receiving objects: 100% (134902/134902), 97.55 MiB | 6.54 MiB/s, done.
Resolving deltas: 100% (103751/103751), done.
MBP:Desktop$cd Nim/
MBP:Nim$./build_all.sh 
git clone -q --depth 1 https://github.com/nim-lang/csources.git
build_nim_csources
/usr/bin/make
make -C csources -j 10 -l 8
makefile:156: *** unknown processor: arm64.  Stop.
cd csources
sh build.sh
# OS: macosx
# CPU: arm
clang -o ../bin/nim -ldl -lm
Undefined symbols for architecture arm64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@Araq
Copy link
Member

Araq commented Jan 21, 2021

You need to use git clone -q --depth 1 https://github.com/nim-lang/csources_v1.git. We need to update the instructions and also migrate our CIs to csources_v1.git.

@joubertnel
Copy link

joubertnel commented Jan 23, 2021

I can confirm that csources_v1.git works getting Nim to compile on M1.

So the following steps worked for me:

(EDIT(timotheecour): I've updated instructions in this commment because people are confused, refs https://forum.nim-lang.org/t/8240#53030):

git clone https://github.com/nim-lang/Nim
cd Nim
sh build_all.sh

git clone -q --depth 1 https://github.com/nim-lang/csources_v1.git csources is not used anymore

@timotheecour
Copy link
Member

timotheecour commented Jan 27, 2021

(for implementation, we could do similarly as was done in #12931 which called dsymutil after a binary was generated)

@elijahr
Copy link
Contributor

elijahr commented Jan 30, 2021

git clone -q --depth 1 https://github.com/nim-lang/csources_v1.git sources

@joubertnel I think this should be git clone … csources, not git clone … sources.

@joubertnel
Copy link

@elijahr you're right; thanks for catching. I updated my original comment so that future readers don't get thrown off.

@timotheecour
Copy link
Member

correct instructions to install nim are:

git clone https://github.com/nim-lang/Nim
cd Nim
sh build_all.sh

(as explained in readme in https://github.com/nim-lang/Nim)
I'm mentioning this because people are confused, refs https://forum.nim-lang.org/t/8240#53030

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants