Commit Graph

155 Commits

Author SHA1 Message Date
alaviss
8e12691213 compiler/extccomp: use getNimcacheDir for writing build instruction (#10772)
`conf.nimcacheDir` might be empty during build, which results in the
json build instructions being generated in the current directory. This
commit fixes the problem by using getNimcacheDir, which generates a
valid nimcacheDir should it be empty.

Fixes #10768
2019-03-04 09:09:14 +01:00
zah
ca4b971bc8 Initial version of the hot-code reloading support for native targets (#10729)
* squashed work by Zahary

* squashing a ton of useful history... otherwise rebasing on top of upstream Nim after commit 82c009a2cb would be impossible.

* Code review changes; Working test suite (without code reloading enabled)

* - documentation
- implemented the HCR test - almost works...
- fix the issue on Unix where for executable targets the source file for the main module of a project in nimcache was being overwritten with the binary itself (and thus the actual source code was lost)
- fixing embedded paths to shared objects on unix (the "lib" prefix was being prepended to the entire path instead of just the filename)
- other fixes
- removing unnecessary includes since that file is already included in chcks.nim which is in turn included in system.nim (and previously was getting imported in chcks.nim but then system.nim improts something... and that breaks HCR (perhaps it could be fixed but it would be nice not to import anything in system))

* fix for clang & C++ - explicitly casting a function pointer to void*
more stable mangling of parameter names when HCR is on
the length of the static arrays in the DatInit functions is now part of the name of the variables, so when they get resized they get also recreated
more stable mangling for inline functions - no longer depends on the module which first used them
work on the new complicated HCR test - turned surprisingly complex - WIP
test now successfully passes even when re-running `koch test` (previously when the nimcache wasn't cold that lead to errors)
better documentation
calling setStackBottomWith for PreMain
passes over the HcrInit/DatInit/Init calls of all modules are now in the proper order (first all of one type, then all of the next). Also typeinfo globals are registered (created) in a single pass before the DatInit pass (because of the way generic instantiations are handled)
Fix the test suite execution on macOs
fix for being able to query the program arguments when using HCR on posix!
other fixes

* Bugfix: Fix a compilation error in C++ mode when a function pointer
is converted to a raw pointer

* basic documentation for the new hot code reloading semantics

* Add change log entry

* Don't re-execute the top-level statements while reloading JS code

* fix a number of tests broken in a recent bugfix

* Review changes

* Added {.executeOnReload.} pragma that indicates top-level statements
  that should be executed on each reload. To make this work, I've modified
  the way the `if (hcr_init_) {...}` guards are produced in the init code.
  This still needs more work as the new guards seem to be inserted within
  the previously generated guards.

  This change also removes the need for `lastRegistedGlobal` in nimhcr.

* Implemented the `signatureHash` magic and the `hasModuleChanged` API
  depending on it (the actual logic is not imlemented yet).

* Add the "hcr" prefix to all HCR-related symbols in the system module.
  Added a new `hotcodereloading` module exporting the high-level API to
  the user.

  Besides being more hygienic, this was also required in order to make
  it possible to use macros in the high-level API. Without the split,
  `system` would have to import `macros`, which was going to produce
  the well-known init problems.

* Attempted to solve the "GC markers problem".

  Crashes were expected with the previous code, because the GC markers
  were compiled as normal procs are registered in the GC. When their
  module is unloaded, dangling pointers will remain in the GC tables.
  To solve this issue, I don't register any GC markers when HCR is on,
  but I add them to the HCR globals metadata and I use a single marker
  registed in nimhcr during the initialization of the system module that
  will be responsible for marking all globals.

* fix a compilation error

* - implemented the hasModuleChanged functionality
- tuples can be returned and broken into different vars in global scope
- added comments for the closnig scopes of the if statements in the init proc
- the new executeOnReload pragma works now!
- other fixes

* finally! fixing this hack in a proper way - declaring the destructor out of line (out of the class body) - we no longer need to forward-declare popCurrentExceptionEx

* Force full module parsing

This is a temporary hack that breaks some tests. I'll investigate
later how these can be fixed.

* tuples are now properly handled when global!

* these comments mess up the codegen in debug mode when $n is not actually a new line (or something like that) - these labels are intended only for GOTO labels anyway...

* "solved" the issue with the .pdb locks on windows when a binary is being debugged and hot code reloading is used at the same time

* fixes after rebasing...

* small fixes for the test

* better handling of globals! no more compiler crashes for locals with the global pragma, also simplified code around loops in global scope which have local vars (actually globals)

* we can now use the global pragma even for ... globals!

* the right output

* lets try those boehm GC tests

* after the test is ran it will be at its starting state - no git modifications

* clarification in the docs

* removed unnecessary line directives for forward declarations of functions - they were causing trouble with hot code reloading when no semantic change propagates to the main module but a line directive got changed and thus the main module had to be recompiled since the .c code had changed

* fixed bug! was inserting duplicate keys into the table and later was removing only 1 copy of all the duplicates (after a few reloads)

* no longer breaking into DatInit code when not supposed to

* fixes after rebasing

* yet more fixes after rebasing

* Update jssys.nim

* Rework the HCR path-handling logic

After reviewing the code more carefully, I've noticed that the old logic
will be broken when the user overrides the '--out:f' compiler option.

Besides fixing this issues, I took the opportunity to implement the
missing '--outdir:d' option.

Other changes:

* ./koch test won't overwrite any HCR and RTL builds located in nim/lib
* HCR and RTL are compiled with --threads:on by default

* Clean up the globals registration logic

* Handle non-flattened top-level stmtlists in JS as well

* The HCR is not supported with the Boehm GC yet

Also fixes some typos and the expected output of the HCR integration test

* The GC marker procs are now properly used as trampolines

* Fix the HCR integration test in release builds

* Fix ./koch tools

* this forward declaration doesn't seem to be necessary, and in fact breaks HCR because a 2nd function pointer is emitted for this externed/rtl func

* the forward declaration I removed in the last commit was actually necessary

* Attempt to make all tests green

* Fix tgenscript

* BAT file for running the HCR integration test on Windows [skip ci]

* Fix the docgen tests

* A final fix for Travis (hopefully)
2019-02-26 15:48:55 +01:00
Timothee Cour
4355f23ee5 fix #10305 nim cpp is now nan-correct at CT (#10310)
* fix #10305 nim cpp is now nan-correct at CT
* add example where simply `nim cpp -d:release` would exhibit nan bug
2019-01-15 14:50:28 +01:00
Neelesh Chandola
642ce799ec Add support for clang-cl (#9977) 2018-12-19 09:35:25 +01:00
Neelesh Chandola
e70c6af188 escape the include path 2018-12-16 14:42:57 +05:30
Neelesh Chandola
c99407b07a Add project directory to include path 2018-12-16 11:39:29 +05:30
Neelesh Chandola
b245b80e72 Fix nimsuggest build with clang on windows 2018-12-13 02:16:29 +05:30
Araq
0ab1229c69 resolve merge conflicts 2018-12-12 18:16:53 +01:00
Araq
46820b94a6 the linking step doesn't mind Windows' 8K command line limit anymore 2018-12-11 21:23:24 +01:00
Araq
77272ceb3c fixes extccomp regressions 2018-12-11 21:23:24 +01:00
Araq
044c7d0921 fixes extccomp regressions 2018-12-11 21:23:23 +01:00
Araq
1946d1a61d fixes extccomp regressions 2018-12-11 21:23:23 +01:00
Araq
8896770f8f workaround against silly Windows command line length limitations for the upcoming megatest.nim 2018-12-11 21:23:23 +01:00
cooldome
9c88df220a Compile pragma. Recompile on external file compilation failure (#9455) 2018-10-22 12:49:57 +02:00
Andreas Rumpf
86556ebfdb compiler refactoring; use typesafe path handing; docgen: render symbols between modules 2018-09-07 19:21:16 +02:00
Charlie Barto
e403ef25ac fix shell quoting error for static libraries (#8532) 2018-08-04 01:18:27 +02:00
Timothee Cour
9e37e3e5e8 add hintCC to optionally disable printing 'CC: filename' (#8479) 2018-08-01 09:22:51 +02:00
Araq
d270245a01 disable --app:gui for non Windows targets; fixes #2576 2018-07-30 12:20:58 +02:00
Joey
2b6f324929 Add -w flag to Switch compilation to prevent deadlock (#8372)
See https://forum.nim-lang.org/t/4062.

The summary is that there are warnings printed when compiling and that causes a deadlock, likely due to output buffers being filled up. With the `-w` flag, the compiler outputs no warnings and the compilation is allowed to finish.
2018-07-20 14:47:19 -05:00
LemonBoy
54a85b4ff5 Give different names to objects coming from cpp files (#8278)
Prevent some nasty linker errors if the user switches between c and cpp
backends.
2018-07-13 15:23:41 +02:00
Joey
559a7615ad Nintendo switch support (#8069)
* Add config section for Nintendo Switch
* Add compiler configuration for Nintendo Switch and it's CPU
* Add specific lib code for Nintendo Switch
* Add GC support for Nintendo Switch
* Update changelog for Nintendo Switch
* Update changelog with more info about fixed paths
* Cleaned up GC memory management a bit
* Relocate docs for Switch
* Rename aarch64NoneElfGcc to nintendoSwitchGCC
* Remove armv8a57
* Fix installer.ini
* Reuse code in linux and amd64
* Add posix defs for nintendo switch
* Add more defined sections for nintendo switch
* Remove old comment
* Add what's not supported for Nintendo Switch docs
* Make nintendoswitch == posix
* Remove DEVKITPRO references from nim.cfg
* Make PR extccomp changes
* Remove Result type alias
* Add separate switch consts file
* Update docs for nintendo switch
* Fix travis errors with undefined consts and add correct wait.h procs
2018-06-27 12:35:09 +02:00
Jörg Wollenschläger
7e89f9a09a Don't remove extension of source files twice, if filenames contain dots 2018-06-26 20:08:40 +09:00
Andreas Rumpf
669a564492 remove more global variables in the Nim compiler 2018-05-27 11:10:56 +02:00
Andreas Rumpf
feef109e60 make tests green again 2018-05-18 20:53:41 +02:00
Andreas Rumpf
a4e2b0c153 platform.nim doesn't use globals anymore; prepare msgs.nim for not using globals 2018-05-18 15:18:00 +02:00
Andreas Rumpf
b2c7910fb6 compiler/ropes.nim has no global error handler anymore 2018-05-17 15:45:41 +02:00
Araq
635451591d extccomp: no globals anymore 2018-05-16 02:01:55 +02:00
Andreas Rumpf
328e7a1005 options.nim: no global variables anymore 2018-05-13 17:52:21 +02:00
Andreas Rumpf
297038f704 move more globals into the config object 2018-05-13 14:19:42 +02:00
Andreas Rumpf
3c4ceea427 move more global variables into ConfigRef 2018-05-11 15:28:26 +02:00
Andreas Rumpf
7eb39d9d26 guards.nim does compile 2018-05-11 13:07:16 +02:00
Andreas Rumpf
61e57cfa13 big refactoring: parser compiles again 2018-05-10 10:49:51 +02:00
genotrance
e931f3b5a9 Fixes #802, #803 and #3775 - genscript issues (#7677)
* Fixes #802, #803 and #3775 - genscript issues

* Test case for genscript

* Test script

* Verify on Linux

* Update categories.nim

* Fix merge

* Improve test framework

* Windows fixes
2018-04-25 10:52:32 +02:00
AdrianV
0ce28d15cc Nim namespace for cpp (#7453)
- new option --usenamespace to generate nim cpp code in its own namespace Nim
- minor changes for compatibility with the new Embarcadero = Borland C++-Builder (bcc)
2018-04-15 13:43:01 +02:00
Andreas Rumpf
70e8640244 move new sha1 module into the new 'std' namespace 2018-02-06 17:40:31 +01:00
Andreas Rumpf
274fafb2df fixes #6961 2018-02-02 17:35:04 +01:00
oltolm
42cff6e0c5 add support for building GUI applications with TCC (#7003) 2017-12-31 14:49:42 +01:00
konqoro
3495c0a46d Fix json generation logic (#6909) 2017-12-21 11:26:02 +01:00
Araq
7a711cc8e1 cleanup of the Intel compiler handling; refs #6488 2017-12-15 19:12:39 +01:00
Eduardo Bart
7c3e00d469 Fix icc compiler on linux (#6488) 2017-12-15 17:01:23 +01:00
Yuriy Glukhov
216119212c Emit relative object file paths in genScript (#6835) 2017-11-29 17:07:16 +01:00
Araq
8aebd38514 fixes #6820 2017-11-28 02:18:23 +01:00
Araq
0e67fc7450 OS X has no llvm-ar tool; use ar instead 2017-11-21 01:45:03 +01:00
Araq
7b63ee85b9 fixes #6452 2017-09-30 15:37:01 +02:00
Andreas Rumpf
7aad0d6544 added 'nim jsonscript' feature 2017-09-23 16:29:05 +02:00
Ruslan Mustakov
31ecec6473 Allow to modify backend link template (#6173) 2017-09-03 01:09:22 +02:00
Araq
733272d55d cleaned up extccomp.nim 2017-07-17 11:42:26 +02:00
Araq
91eba77b96 fixes #4763 2017-07-17 09:28:03 +02:00
Fredrik Høisæther Rasch
392f025148 Error Message if CC invocation fails (#5663) 2017-04-08 19:06:19 +02:00
Emery Hemingway
d508303fad fix empty link file list during external compilation (#5577) 2017-03-23 13:27:16 +01:00