Граф коммитов

506 Коммитов

Автор SHA1 Сообщение Дата
Alan Wu a1435981e9 [DOC] Document RbConfig::SIZEOF 2024-07-15 21:08:13 -04:00
Alan Wu 3531d22918 [DOC] Document RbConfig::LIMITS 2024-07-15 21:08:13 -04:00
Alan Wu 9bf1049dfb Refactor so RDoc picks up RbConfig::{SIZEOF,LIMITS} 2024-07-15 21:08:13 -04:00
Peter Zhu 6fc83118bb Fix Makefile.in for non GNUmake
On OpenBSD the Makefile errors with:

    Using $< in a non-suffix rule context is a GNUmake idiom
2024-07-11 15:49:14 -04:00
Peter Zhu a0469a4788 Rename gc/gc_impl.c to gc/default.c
Changing the name makes it clear that this is the default GC in Ruby.
2024-07-11 09:09:47 -04:00
Peter Zhu e5d12f9cce Move gc_impl.c to gc/gc_impl.c
This commit creates a new directory `gc` to put different GC
implementations and moves the default GC from gc_impl.c to gc/gc_impl.c.
The default GC can be easily switched using the `BUILTIN_GC` variable
in Makefile.in.
2024-07-11 09:09:47 -04:00
Peter Zhu a9f6bd028a Add make target shared-gc
Allows building shared GC using `make shared-gc SHARED_GC=gc_impl`
2024-07-08 16:47:25 -04:00
KJ Tsanaktsidis dface4427d Also export CC for dtrace's benefit as well
The CFLAGS might contain flags that only work with the specified CC
2024-07-07 22:37:36 +10:00
KJ Tsanaktsidis 3381c60836 Ensure CFLAGS are passed to probes.o generation
The dtrace python script from systemtap on Linux actually looks at the
CFLAGS environment variable when invoking gcc to make the probes.o file.
If we don't pass the CFLAGS we're using, this probes.o file can wind up
without the required annotations indicating that it supports e.g. Intel
CET.

Fix this by explicitly exporting our build flags to the environment for
this script.

[Bug #18061]
2024-07-07 20:14:44 +10:00
KJ Tsanaktsidis b18701a7ae Remove $(ASFLAGS) from build system and assemble with $(CFLAGS) instead
We already assemble our assembly files using the $(CC) compiler driver,
rather than the actual $(AS) assembler. This means that

* The C preprocessor gets run on the assembly file
* It's valid to pass gcc-style flags to it, like e.g.
  -mbranch-protection or -fcf-protection
* If you do so, the relevant preprocessor macros like __CET__ get set
* If you really wanted to pass assembler flags, you would need to do
  that using -Wa,... anyway

So I think it makes sense to pass "$(XCFLAGS) $(CFLAGS) $(CPPFLAGS)" to
gcc/clang/etc when assembling, rather than passing $(ASFLAGS) (since
the flags are not actually passed to `as`, but `cc`!).

The side effect of this is that if there are mitigation flags like
-fcf-protection in $CFLAGS, then the relevant macros like __CET__ will
be defined when assembling the files.

[Bug #20601]
2024-07-07 20:14:44 +10:00
Nobuyoshi Nakada 1213623e5c
Use gperf 3.1 to generate ANSI-C code 2024-06-24 23:43:45 +09:00
KJ Tsanaktsidis 0ccb80d6bf Extract hardening CFLAGS to a special $hardenflags variable
This changes the automatic detection of -fstack-protector,
-D_FORTIFY_SOURCE, and -mbranch-protection to write to $hardenflags
instead of $XCFLAGS. The definition of $cflags is changed to
"$hardenflags $orig_cflags $optflags $debugflags $warnflags" to match.

Furthermore, these flags are _prepended_ to $hardenflags, rather than
appended.

The implications of doing this are as follows:

* If a CRuby builder specifies cflags="-mbranch-protection=foobar" at
  the ./configure script, and the configure script detects that
  -mbranch-protection=pac-ret is accepted, then GCC will be invoked as
  "gcc -mbranch-protection=pac-ret -mbranch-protection=foobar". Since
  the last flags take precedence, that means that user-supplied values
  of these flags in $cflags will take priority.
* Likewise, if a CRuby builder explicitly specifies
  "hardenflags=-mbranch-protection=foobar", because we _prepend_ to
  $hardenflags in our autoconf script, we will still invoke GCC as
  "gcc -mbranch-protection=pac-ret -mbranch-protection=foobar".
* If a CRuby builder specifies CFLAGS="..." at the configure line,
  automatic detection of hardening flags is ignored as before.
* C extensions will _also_ be built with hardening flags now as well
  (this was not the case by default before because the detected flags
  went into $XCFLAGS).

Additionally, as part of this work, I changed how the detection of
PAC/BTI in Context.S works. Rather than appending the autodetected
option to ASFLAGS, we simply compile a set of test programs with the
actual CFLAGS in use to determine what PAC/BTI settings were actually
chosen by the builder. Context.S is made aware of these choices through
some custom macros.

The result of this work is that:

* Ruby will continue to choose some sensible defaults for hardening
  options for the C compiler
* Distributors are able to specify CFLAGS that are consistent with their
  distribution and override these defaults
* Context.S will react to whatever -mbranch-protection is actually in
  use, not what was autodetected
* Extensions get built with hardening flags too.

[Bug #20154]
[Bug #20520]
2024-06-11 20:48:55 +10:00
Nobuyoshi Nakada 26bd4144f7
Add `nightly` recipe
Installs the last revision in the previous `RUBY_RELEASE_DATE`.
2024-06-02 18:36:09 +09:00
Kevin Newton 4e36abbab3 [PRISM] Support for compiling builtins 2024-05-30 15:38:02 -04:00
eileencodes 0f9e50b8c5 Fix macos bug deleting too many files
Since #10209 we've been noticing that on macos after running `make
clean` the `coroutine/arm64/Context.S` file is missing, causing
subsequent make calls to fail because `Context.S` is needed to build
`Context.o`.

The reason this is happening is because macos is case-insensitive so the
`.s` looks for `coroutine/arm64/Context.s` and finds
`coroutine/arm64/Context.s`. This does not happen on linux because the
filesystem is case sensitive.

I attempted to use `find` because it is case sensitive regardless of
filesystem, but it was a lot slower than `rm` since we can't pass
multiple file names the same way to `find`.

Reverting this small part of #10209 fixes the issue for macos and it
wasn't clear that those changes were strictly necessary for the rest of
the PR.

We changed the original code to use `rm` instead of `delete` because it
is not standarized on POSIX.
2024-05-26 19:11:23 +09:00
Hiroshi SHIBATA 9df3f205b1 test-syntax-suggest is not working with mswin environment 2024-05-09 15:22:53 +09:00
yui-knk 899d9f79dd Rename `vast` to `ast_value`
There is an English word "vast".
This commit changes the name to be more clear name to avoid confusion.
2024-05-03 12:40:35 +09:00
HASUMI Hitoshi 2244c58b00 [Universal parser] Decouple IMEMO from rb_ast_t
This patch removes the `VALUE flags` member from the `rb_ast_t` structure making `rb_ast_t` no longer an IMEMO object.

## Background

We are trying to make the Ruby parser generated from parse.y a universal parser that can be used by other implementations such as mruby.
To achieve this, it is necessary to exclude VALUE and IMEMO from parse.y, AST, and NODE.

## Summary (file by file)

- `rubyparser.h`
  - Remove the `VALUE flags` member from `rb_ast_t`
- `ruby_parser.c` and `internal/ruby_parser.h`
  - Use TypedData_Make_Struct VALUE which wraps `rb_ast_t` `in ast_alloc()` so that GC can manage it
    - You can retrieve `rb_ast_t` from the VALUE by `rb_ruby_ast_data_get()`
  - Change the return type of `rb_parser_compile_XXXX()` functions from `rb_ast_t *` to `VALUE`
  - rb_ruby_ast_new() which internally `calls ast_alloc()` is to create VALUE vast outside ruby_parser.c
- `iseq.c` and `vm_core.h`
  - Amend the first parameter of `rb_iseq_new_XXXX()` functions from `rb_ast_body_t *` to `VALUE`
  - This keeps the VALUE of AST on the machine stack to prevent being removed by GC
- `ast.c`
  - Almost all change is replacement `rb_ast_t *ast` with `VALUE vast` (sorry for the big diff)
  - Fix `node_memsize()`
    - Now it includes `rb_ast_local_table_link`, `tokens` and script_lines
- `compile.c`, `load.c`, `node.c`, `parse.y`, `proc.c`, `ruby.c`, `template/prelude.c.tmpl`, `vm.c` and `vm_eval.c`
  - Follow-up due to the above changes
- `imemo.{c|h}`
  - If an object with `imemo_ast` appears, considers it a bug

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2024-04-26 11:21:08 +09:00
HASUMI Hitoshi 9b1e97b211 [Universal parser] DeVALUE of p->debug_lines and ast->body.script_lines
This patch is part of universal parser work.

## Summary
- Decouple VALUE from members below:
  - `(struct parser_params *)->debug_lines`
  - `(rb_ast_t *)->body.script_lines`
- Instead, they are now `rb_parser_ary_t *`
  - They can also be a `(VALUE)FIXNUM` as before to hold line count
- `ISEQ_BODY(iseq)->variable.script_lines` remains VALUE
  - In order to do this,
  - Add `VALUE script_lines` param to `rb_iseq_new_with_opt()`
  - Introduce `rb_parser_build_script_lines_from()` to convert `rb_parser_ary_t *` into `VALUE`

## Other details
- Extend `rb_parser_ary_t *`. It previously could only store `rb_parser_ast_token *`, now can store script_lines, too
- Change tactics of building the top-level `SCRIPT_LINES__` in `yycompile0()`
  - Before: While parsing, each line of the script is added to `SCRIPT_LINES__[path]`
  - After: After `yyparse(p)`, `SCRIPT_LINES__[path]` will be built from `p->debug_lines`
- Remove the second parameter of `rb_parser_set_script_lines()` to make it simple
- Introduce `script_lines_free()` to be called from `rb_ast_free()` because the GC no longer takes care of the script_lines
- Introduce `rb_parser_string_deep_copy()` in parse.y to maintain script_lines when `rb_ruby_parser_free()` called
  - With regard to this, please see *Future tasks* below

## Future tasks
- Decouple IMEMO from `rb_ast_t *`
  - This lifts the five-members-restriction of Ruby object,
  - So we will be able to move the ownership of the `lex.string_buffer` from parser to AST
  - Then we remove `rb_parser_string_deep_copy()` to make the whole thing simple
2024-04-15 20:51:54 +09:00
Nobuyoshi Nakada ca81f5a5de
Realclean extracted bundled gems and lock files 2024-04-11 23:47:32 +09:00
Nobuyoshi Nakada 2df4638538
Cleanings of .bundle do not need cleanings of ext 2024-04-11 23:47:32 +09:00
Nobuyoshi Nakada 7c015c3b30
Remove never used macros related to RJIT [ci skip]
These macros have not been used since the commit "Stop exporting
symbols for MJIT" 233ddfac54, and
renamed as RJIT.
2024-03-24 22:37:20 +09:00
Takashi Kokubun cbcb2d46fc
[DOC] Unify Doxygen formats (#10285) 2024-03-19 10:59:25 -07:00
Nobuyoshi Nakada 5fd6b461c7
Refactor encdb and transdb templates
- Simplify globbed file names.
- Prefer `File.open` over `Kernel#open`.
- Swallow initializer blocks instead of line by line with flip-flop.
- Re-structure converter list.
2024-03-17 19:09:37 +09:00
Nobuyoshi Nakada 9e470ebdcd
Revert "Remove flip-flop usages from build scripts"
This reverts commit 301fa452f7.
2024-03-17 18:28:28 +09:00
Nobuyoshi Nakada 9f60fd9d89
Ignore failures on removing ext sub directories
When multiple libraries exist in a subdirectory under `ext`, `rmdir
-p` may fail, because other directories have not been removed yet or
the parent directory has been removed by other `distclean`.  `rmdir`
in GNU coreutils has `--ignore-fail-on-non-empty` option for the
former case but others may not, and the latter race condition is not
avoidable anyway.
2024-03-11 00:46:15 +09:00
Nobuyoshi Nakada 0fb39ab1b9
Clean intermediate files and debug info for each target
By replacing `ALLOBJS` suffix with intermediate file suffixes instead
of roughly removing by wildcards.  Made `cleanlibs` append `.dSYM`
suffix for each word in `TARGET_SO`, not the end of the entire list.
2024-03-10 22:12:00 +09:00
Nobuyoshi Nakada 69cfcd46c2
Remove duplicate dependency line 2024-03-08 11:58:41 +09:00
Nobuyoshi Nakada 1c083c4db0
Clean up files made by runnable in clean-runnable [ci skip] 2024-03-07 16:40:27 +09:00
Nobuyoshi Nakada d1c66456b8
Ingore errors when removing intermediate files recursively [ci skip] 2024-03-07 16:29:48 +09:00
Yuta Saito fd91354628 [DOC] Comment about logic to care about static/dynamic hetero build
The condition is rarely met in usual cases, so it's worth to note about
the situation and the reason why we care about it.
2024-02-21 19:37:06 +09:00
Nobuyoshi Nakada ae8990aef0
Alias init functions
The extension library has each initialization function named "Init_" +
basename. If multiple extensions have the same base name (such as
cgi/escape and erb/escape), the same function will be registered for
both names.

To fix this conflict, rename the initialization functions under sub
directories using using parent names, when statically linking.
2024-02-04 16:43:09 +09:00
Nobuyoshi Nakada c68ce6f7f5
Skip checking for symbol leaks in libruby.so linking extensions
The libruby.so linking extension libraries contain symbols exported
from extension libraries, and is not subject of test-leaked-globals.
2024-01-17 19:37:56 +09:00
Nobuyoshi Nakada 772413245f
Skip checking for symbol leaks in libruby.a linking extensions
The libruby.a linking extension libraries contain symbols exported
from extension libraries, and is not subject of test-leaked-globals.
2024-01-14 23:38:47 +09:00
Nobuyoshi Nakada 3edb7f1a07
[DOC] Documentize known_errors 2024-01-13 11:08:00 +09:00
Mikhail Doronin ae2c4d0720 Revert "[Bug #19831] Remove duplicate library options"
This reverts commit 5bb9462285.

Fixes https://bugs.ruby-lang.org/issues/20072
2023-12-20 13:46:39 +09:00
Nobuyoshi Nakada 6e8ad7497e
Move `DOT_WAIT` before including Makefile that is using it [ci skip] 2023-12-10 13:55:19 +09:00
Nobuyoshi Nakada 22939382a8 [Bug #18286] Make builtin binary if sharable in universal binaries 2023-11-09 16:01:01 +09:00
Nobuyoshi Nakada 40d40a651e Revert "Disable iseq-dumped builtin module for universal x86_64/arm64 binaries"
This reverts commit 1d5598fe0d.
2023-11-09 16:01:01 +09:00
Ben Hamilton 1d5598fe0d Disable iseq-dumped builtin module for universal x86_64/arm64 binaries
During the build, Ruby has special logic to serialize its own builtin
module to disk using the binary iseq format during the build (I assume
for speed so it doesn't have to parse builtin every time it starts
up).

However, since iseq format is architecture-specific, when building on
x86_64 for universal x86_64 + arm64, the serialized builtin module is
written with the x86_64 architecture of the build machine, which fails
this check whenever ruby imports the builtin module on arm64:

1fdaa06660/compile.c (L13243)

Thankfully, there's logic to disable this feature for cross-compiled builds:

1fdaa06660/builtin.c (L6)

This disables the iseq logic for universal builds as well.

Fixes [Bug #18286]
2023-11-09 12:24:01 +09:00
Nobuyoshi Nakada 665b4c5b2a
[Bug #19967] Reset `LIBPATHENV` env after started
Not to affect other tools invoked as child processes.
2023-10-21 14:05:20 +09:00
Nobuyoshi Nakada 96cd73d78f
Ignore symbols even in empty shared library
On some platforms, such as FreeBSD and Oracle Linux, symbols defined
in the crt0 setup routine are exported from shared libraries.  So
ignore the symbols that would be exported even in an empty shared
library.
2023-10-14 18:38:24 +09:00
Nobuyoshi Nakada 20bd19a9ad
Move YARP_BUILD_DIR to common.mk
It does not need to be an absolute path.
2023-09-21 18:18:27 +09:00
Nobuyoshi Nakada bcb3247072
[Bug #19778] Pass additional include options to INCFLAGS in common.mk 2023-09-17 19:18:23 +09:00
Nobuyoshi Nakada 5ec1fc52c1
Escape non-ascii characters in prelude C comments
Non-ASCII code are often warned by localized compilers.
2023-08-24 21:12:51 +09:00
Nobuyoshi Nakada 5bb9462285 [Bug #19831] Remove duplicate library options
`$(MAINLIBS)` should be included in `$(LIBRUBYARG)` in cases it is
needed.
2023-08-17 10:57:09 +09:00
Nobuyoshi Nakada f339937abb RJIT: Remove macros inherited from MJIT but no longer used 2023-08-17 08:33:52 +09:00
Nobuyoshi Nakada 2a3acbc420
Fix test and precheck order for old GNU Make 2023-08-14 11:30:05 +09:00
Nobuyoshi Nakada 475241ee91
Group test-syntax-suggest and leaked-globals [ci skip] 2023-08-11 16:22:18 +09:00
Nobuyoshi Nakada b7453b91dc
[Bug #19831] Remove duplicate library options
`$(MAINLIBS)` should include `$(LIBS)` already.
2023-08-11 09:46:46 +09:00