| Age | Commit message (Collapse) | Author |
|
This adds a build_config that will cross-build a Windows executable
using the MinGW cross-compiler and will also run the unit (i.e.
'rake test') using Wine.
For this to work, I made some modifications to the underlying test
scripts as well as some minor changes to a couple of the tests
themselves.
|
|
|
|
|
|
|
|
dearblue-reorganize-ci
|
|
|
|
If there is `env`, `env->c` means `target_class`.
|
|
The accuracy is greatly improved by using the C preprocessor to scan C
sources for presym. C preprocessor can perfectly interpret all comments and
preprocessor directives, so it can detect all symbols defined, for example
`mrbgems/mruby-socket/src/const.cstub`.
Also, as described later, this change will greatly improve the accuracy of
presym detection from Ruby sources.
## Result
The number of lines in the `presym` file for all gems is as follows:
```console
Previous: 999 (false positive = 89, undetected = 297)
New: 1207
```
## Build process
The new build process (with presym) is as follows:
1. Build `mrbc` without presym (more on building without presym later).
2. Compile Ruby sources to C struct format with the `mrbc` created in
step 1, and create` mrblib.c` and `gem_init.c`. Note that the symbols
in the created files are output as `MRB_SYM` family macros or
`mrb_intern_lit` instead of IDs (details will be described later).
3. C preprocessor processes C sources including the created files of
step 2 and outputs them as `.i` files. In these files, for example,
`MRB_IVSYM(foo)` is converted to `<@! "@" "foo" !@>` and
`mrb_define_module(mrb, "Foo")` is converted to `<@! "Foo" !@>`.
4. Scan the files created in step 3 and create `presym` and` presym.inc`
files.
The files created in step 2 should output all static symbols defined in Ruby
sources, including local variables, so we can detect all presyms by just
scanning C sources without scanning Ruby sources directly.
Further, by this process, the files to be scanned becomes the same as the
files to be compiled, so that there is no excess or deficiency.
## Related changes
The following changes have been made in relation to realizing this feature.
### Allow build without presym
It enables build without presym to achieve the "Build process: 1". This
incorporates #5202, see its issue for details.
Note that when presym is enabled, even adding a local variable to a Ruby
source may change contents of presym and require recompilation of almost
all C sources. This is inconvenient, especially during trial and error in
development, but this feature is also useful because it does not cause
this problem if presym is disabled.
### Automatically create build target for `mrbc` without presym
The `mrbc` used in the "Build process: 1" will be built by automatically
creating a build target for it. The build name is `SOURCE_BUILD_NAME/mrbc`.
### Constantize output of C struct format by `mrbc`
To realizing the "Build process: 2", as mentioned above, symbol IDs are not
output directly in C struct format output by `mrbc`. As a result, the output
becomes constant regardless of the state of presym at the time of `mrbc`
build, and it is possible to detect symbols of Ruby sources in the same way
as other C sources.
Note that `mrb_intern_lit` is used for symbols that do not become presym,
but in this state, the corresponding element in the symbol array cannot be
statically initialized, so it is initialized at run time (therefore, in this
case, the `const` qualifier is not added to the symbol array).
### Specify arbitrary `mrbc` file
To realizing the "Build process: 2", enabled to specify `mrbc` created by
another build target or pre-built` mrbc`. Use `MRuby::Build#mrbcfile =` to
specify it explicitly. You can omit the "Build process: 1" by specifying
pre-built `mrbc`, and you can always use an optimized build to compile Ruby
sources faster. I think changes that affect the output of `mrbc` are rare,
so in many cases it helps to improve efficiency.
With presym, the build will be a little slower due to more build steps, but
this feature will improve it a bit.
### Create presym files for each build target
This feature was proposed at #5194 and merged once, but was reverted in
5c205e6e due to problems especially with cross-compilation. It has been
introduced again because this change solves the problem.
The presym files will be created below.
* `build/NAME/presym`
* `build/NAME/include/mruby/presym.inc`
### Other changes
* Because presym detection accuracy is greatly improved as mentioned above,
`MRuby::Gem::Specification#cdump?` is set to true by default, and
`disable_cdump` is added instead of `enable_cdump`. Also, support for gem
specific presym files has been discontinued (https://github.com/mruby/mruby/issues/5151#issuecomment-730967232).
* Previously, `mrbc` was automatically created for the `host` build, but it
will not be created if the build target for `mrbc` mentioned above is
automatically created. At this time, `mrbc` file of the `mrbc` build is
copied to` bin/`.
* Two types of `.d` files will be created, `.o.d` and `.i.d`. oThis is
because if `.i` depends on `presym.inc`, the dependency will circulate, so
the `.d` file cannot be shared.
* Changed file created with `enable_cxx_exception` to `X-cxx.cxx` from
`X.cxx` to use the mruby standard Rake rule.
### Note
Almost all C sources will need to be recompiled if there are any changes to
`persym.inc` (if not recompiled properly, it will often result in run-time
error). If `gcc` toolchain is used, dependencies are resolved by the `.d`
file, so it become automatically recompile target, but if not (e.g. MSVC),
it is necessary to manually make it recompile target.
Also, even if `gcc` toolchain is used, it may not become recompile target if
external gems does not use the mruby standard Rake rule. In particular, if
the standard rule is overwritten, such as
https://github.com/mruby/mruby/pull/5112/files, `.d` file will not be read,
so be careful.
|
|
| Previous Name | New Name |
|------------------------------|-------------------------|
| MRB_ENABLE_ALL_SYMBOLS | MRB_USE_ALL_SYMBOLS |
| MRB_ENABLE_SYMBOLL_ALL | MRB_USE_ALL_SYMBOLS |
| MRB_ENABLE_CXX_ABI | MRB_USE_CXX_ABI |
| MRB_ENABLE_CXX_EXCEPTION | MRB_USE_CXX_EXCEPTION |
| MRB_ENABLE_DEBUG_HOOK | MRB_USE_DEBUG_HOOK |
| MRB_DISABLE_DIRECT_THREADING | MRB_NO_DIRECT_THREADING |
| MRB_DISABLE_STDIO | MRB_NO_STDIO |
| ENABLE_LINENOISE | MRB_USE_LINENOISE |
| ENABLE_READLINE | MRB_USE_READLINE |
| DISABLE_MIRB_UNDERSCORE | MRB_NO_MIRB_UNDERSCORE |
| DISABLE_GEMS | MRB_NO_GEMS |
* `MRB_ENABLE_SYMBOLL_ALL` seems to be a typo, so it is fixed.
* `MRB_` prefix is added to those without.
* The previous names can also be used for compatibility.
|
|
It is not decides by the extension.
In order to be recognized as a `.mrb` file, the following three points must be satisfied:
- File starts with "RITE"
- At least `sizeof(struct rite_binary_header)` bytes can be read
- `NUL` is included in the first 64 bytes of the file
If these are not met, it is judged as a text file and it is processed as a Ruby script.
The `bin/mruby -b` switch is still available which treats the given file as a `.mrb` file.
New `MRB_API` function:
- `include/mruby/compile.h` and `mrbgems/mruby-compiler/core/parse.y`
- `mrb_load_detect_file_cxt()` (remove with `MRB_DISABLE_STDIO`)
NOTE:
- Even script files now always open in binary mode for `bin/mruby`.
The `\r\n` is handled by the `nextc()` function already, so there is no problem even on Windows.
- The `nextc0()` function in `mrbgems/mruby-compiler/core/parse.y` can now specify a string buffer and a file pointer at the same time.
In this case, get it from the string buffer first.
This patch includes modifies by comment of https://github.com/mruby/mruby/pull/5157.
|
|
|
|
In addition, update the documents referring `build_config.rb` which is
no longer used. The new `build_config.rb` describes the new configuration
structure in the comment.
|
|
Fix take over file scope variables with `mruby` and `mirb` command
|
|
|
|
ref #4576 and ref #4947
* Need MRBAPI functions without `MRB_DISABLE_STDIO`:
* mrbgems/mruby-bin-debugger
* mrbgems/mruby-bin-mirb
* mrbgems/mruby-bin-mrbc
* mrbgems/mruby-bin-mruby
* mrbgems/mruby-bin-strip
* Need `stdio.h`:
* mrbgems/mruby-io
* mrbgems/mruby-print
* Need `snprintf()` in `stdio.h`:
* mrbgems/mruby-pack
* mrbgems/mruby-sprintf
|
|
'stdio.h' is included in 'mruby.h' ('mrbconf.h').
However, keep 'stdio.h' used by mruby-test.
|
|
|
|
|
|
Resolve #4931
|
|
|
|
|
|
#### Before this patch:
```
$ bin/mruby --verbose -e 'p 1'
bin/mruby: Cannot open program file: --verbose
```
#### After this patch:
```
$ bin/mruby --verbose -e 'p 1'
00001 NODE_SCOPE:
(snip)
irep 0x7fe97041df30 nregs=4 nlocals=1 pools=0 syms=1 reps=0 iseq=11
file: -e
1 000 OP_LOADSELF R1
(snip)
1
```
|
|
#### Before this patch:
```
$ bin/mruby -e 'p ARGV' -- -x
bin/mruby: invalid option -- (-h will show valid options)
```
#### After this patch:
```
$ bin/mruby -e 'p ARGV' -- -x
["-x"]
```
|
|
#### Before this patch:
```
$ bin/mruby -e 'p ARGV' a b
["bin/mruby", "-e", "p ARGV", "a", "b"]
```
#### After this patch:
```
$ bin/mruby -e 'p ARGV' a b
["a", "b"]
```
|
|
#### Before this patch:
```
$ bin/mruby -ce 1
bin/mruby: Cannot open program file: 1
```
#### After this patch:
```
$ bin/mruby -ce 1
Syntax OK
```
|
|
|
|
- I think "Info" is used only to `skip`, so change to "Skip".
- Changed the default value of `assert` and specify the argument explicitly
at the caller of `assert` because it is unnatural "Assertion failed" is
output even though the assertion doesn't fail.
== Example:
def assert_foo(exp, act)
assert do
assert_equal exp[0], act[0]
assert_equal exp[1], act[1]
end
end
def assert_bar(exp, act)
assert do
skip
end
end
def assert_baz(exp, act)
assert do
assert_equal exp, act
assert_bar exp, act
end
end
assert 'test#skip_in_nested_assert' do
assert_baz 1, 1
end
=== Before this patch:
?..
Info: test#skip_in_nested_assert (core)
- Assertion[1]
Info: Assertion failed (core)
- Assertion[1-2]
Skip: Assertion failed (core)
Total: 3
OK: 2
KO: 0
Crash: 0
Warning: 0
Skip: 1
=== After this patch:
???
Skip: test#skip_in_nested_assert (core)
- Assertion[1]
Skip: assert (core)
- Assertion[1-2]
Skip: assert (core)
Total: 3
OK: 0
KO: 0
Crash: 0
Warning: 0
Skip: 3
|
|
|
|
|
|
- Modify some error messages for consistency.
- Add test for codegen error.
- Use regular expression for error message matching in test.
|
|
- Write message to stderr instead of stdout.
- Avoid duplicate message output (`SyntaxError`, `ScriptError` etc).
- Refine invalid option message.
- Suppress redundant usage output.
- Fix some incorrect exit code.
|
|
|
|
Example:
# example.rb
p(2e308)
p(-2e308)
Good:
$ bin/mruby example.rb
inf
-inf
Bad:
$ bin/mrbc example.rb
$ bin/mruby -b example.mrb
0
-0
Cause:
Float infinity representation is `inf` on dump and it is converted by
corresponding `String#to_f` on load.
Treatment:
- Introduce new representations (`i`: +infinity, `I`: -infinity)
- Allow old representations (`inf`, `-inf`, `infinity`, `-infinity`) too
- Raise error for unknown representations (use corresponding `Kernel#Float`)
|
|
`Kernel#p` etc are used.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
There are 3 levels of C++ exception handling:
* default - no C++ exception (use setjmp/longjmp)
* enable_cxx_exception (use C++ exceptions with C ABI)
* enable_cxx_abi (use C++ ABI including exceptions)
|
|
|
|
|
|
|
|
Reported by https://hackerone.com/haquaman
|
|
|
|
|
|
changes:
* rename DISABLE_STDIO -> MRB_DISABLE_STDIO
* rename ENABLE_DEBUG -> MRB_ENABLE_DEBUG_HOOK
* no more opposite macro definitions (e.g. ENABLE_STDIO, DISABLE_DEBUG).
* rewrite above macro references throughout the code.
* update documents
|