Commit graph

131 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
Takashi Kokubun
38be9a9b72
Clean up OPT_STACK_CACHING (#8132) 2023-07-27 17:27:05 -07:00
Nobuyoshi Nakada
cceb410087 leaked-globals: check leaked symbols in libruby.so if enable-shared 2023-07-08 11:31:17 +09:00
Jemma Issroff
d53e1f42ff [Feature #19741] Add yarp to builds
Add yarp to common.mk and windows builds to enable us to run yarp
correctly with CI.
2023-06-21 11:25:39 -07:00
Yuichiro Kaneko
a1b01e7701
Use Lrama LALR parser generator instead of Bison
https://bugs.ruby-lang.org/issues/19637

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2023-05-12 18:25:10 +09:00
Nobuyoshi Nakada
2f1586f6f2 Check leaked global symbols by default 2023-04-03 10:07:22 +09:00
Takashi Kokubun
2e875549a9 s/MJIT/RJIT/ 2023-03-06 23:44:01 -08:00
Takashi Kokubun
011c08b643 Remove obsoleted mjit_sp_inc.inc.erb 2023-03-06 23:05:50 -08:00
Takashi Kokubun
b2130d5f5d Remove obsoleted tool/mjit_tabs.rb 2023-03-06 22:53:38 -08:00
Takashi Kokubun
2702d615f5 Remove obsoleted mjit_config.h 2023-03-06 22:31:43 -08:00
Takashi Kokubun
f68580890f Stop building mjit_build_dir.so 2023-03-06 22:14:44 -08:00
Takashi Kokubun
31f4b2d86b
Drop obsoleted MJIT header (#7458)
RJIT doesn't need this.
2023-03-06 21:41:48 -08:00
Alan Wu
675e296641
Add .DELETE_ON_ERROR to Makefile
This instructs make to delete target files if the recipe fails midway, like
when make itself is interrupted. This is mostly for development since it
protects against corrupt builds that need a `make clean` to repair. Release
builds normally don't fail mid-recipe.

GNU make and BSD make support this.

From GNU make's manual:

> This is almost always what you want make to do, but it is not historical
> practice; so for compatibility, you must explicitly request it. 

See https://innolitics.com/articles/make-delete-on-error/
2023-02-06 14:50:06 -05:00
Nobuyoshi Nakada
be81495c16
Silence dozens of useless warnings from nm on macOS 2023-01-31 19:42:01 +09:00
Alan Wu
7d4395cb69 YJIT: Fix shared/static library symbol leaks
Rust 1.58.0 unfortunately doesn't provide facilities to control symbol
visibility/presence, but we care about controlling the list of
symbols exported from libruby-static.a and libruby.so.

This commit uses `ld -r` to make a single object out of rustc's
staticlib output, libyjit.a. This moves libyjit.a out of MAINLIBS and adds
libyjit.o into COMMONOBJS, which obviates the code for merging libyjit.a
into libruby-static.a. The odd appearance of libyjit.a in SOLIBS is also
gone.

To filter out symbols we do not want to export on ELF platforms, we use
objcopy after the partial link. On darwin, we supply a symbol list to
the linker which takes care of hiding unprefixed symbols.

[Bug #19255]

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2023-01-27 12:28:09 -05:00
Nobuyoshi Nakada
1e2523fad7
Silence dozens of useless warnings from ranlib on macOS [ci skip] 2023-01-23 19:02:36 +09:00
Nobuyoshi Nakada
418b03c750
tool/leaked-globals: ignore function typedef [ci skip] 2023-01-21 19:26:16 +09:00
Hiroshi SHIBATA
18d8333c30 Switch to use gem version of simplecov, not git clone 2023-01-18 20:19:08 +09:00
Nobuyoshi Nakada
1ddeb7473d
Move the dependency of makefiles on revision header [ci skip]
Since `REVISION_H` is defined in common.mk which is appended or
included after Makefile.in, it was undefined yet at the point of the
dependency.
2023-01-14 20:30:19 +09:00
Nobuyoshi Nakada
5716c0f1f8
MSVS lacks touch [ci skip] 2022-12-20 17:53:41 +09:00
Nobuyoshi Nakada
0344283fd3
Fix missing parentheses [ci skip] 2022-12-20 16:07:10 +09:00
Nobuyoshi Nakada
30379e33c3
Handle depend files on nmake 2022-12-05 17:09:49 +09:00
Takashi Kokubun
a1d70f5b12 MJIT: Rename mjit_compile_attr to mjit_sp_inc
There's no mjit_compile.inc, so no need to use this prefix anymore.
2022-11-29 21:45:34 -08:00
Nobuyoshi Nakada
60f12c7d2e
Fix infinite loop when out-of-place build 2022-11-02 11:33:08 +09:00
Hiroshi SHIBATA
a25c033805 Suppress warning for fgrep
>fgrep: warning: fgrep is obsolescent; using ggrep -F
2022-10-19 21:10:00 +09:00