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

594 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada a01271c1c4
BOOTSTRAPRUBY needs fake.rb when cross-compiling 2022-09-03 21:37:24 +09:00
Nobuyoshi Nakada 7c67d0fd79
Make sources by BASERUBY if available instead of miniruby 2022-09-03 19:25:29 +09:00
Nobuyoshi Nakada 6f5305e0d2
Exclude LIBPATHENV wrapper from PREP 2022-09-03 19:20:03 +09:00
Nobuyoshi Nakada 21a5da3c4c
Check if MSys shell can run a command with a drive letter 2022-09-03 19:20:03 +09:00
Nobuyoshi Nakada cd1a0b3caa Stop defining `RUBY_ABI_VERSION` if released versions
As commented in include/ruby/internal/abi.h, since teeny versions of
Ruby should guarantee ABI compatibility, `RUBY_ABI_VERSION` has no role
in released versions of Ruby.
2022-08-12 15:57:25 +09:00
Nobuyoshi Nakada 74d95744bd
Add `--enable-devel` configure option
Since `RUBY_DEVEL` in cppflags has no effect in the configure script
and makefiles.
2022-08-11 11:34:52 +09:00
Jeremy Evans 357352af5e Do not enable RUBY_DEVEL by RUBY_PATCHLEVEL
This makes RUBY_DEVEL not enabled automatically.  It still can be
enabled manually.

Test manually using RUBY_DEVEL in CI.

Implements [Feature #17468]
2022-08-09 22:13:17 -07:00
Yuta Saito 184fd94d7e Resolve abi symbols from libruby.dylib when available 2022-08-04 16:29:22 +09:00
Yuta Saito 6d8b9a9d61 Resolve abi symbol references from miniruby to avoid circular deps
Adding `ruby` to `PREP` causes the following circular dependencies
because `PREP` is used as a prerequisite by some targets required to
build `ruby` target itself.
```
make: Circular .rbconfig.time <- ruby dependency dropped.
make: Circular builtin_binary.inc <- ruby dependency dropped.
make: Circular ext/extinit.c <- ruby dependency dropped.
make: Circular ruby <- ruby dependency dropped.
```

Adding a new Make variable like `EXTPREP` only for exts may be also
reasonable, but it would introduce another complexity into our build
system. `-bundle_loader` doesn't care that link-time and run-time
loader executables are different as long as bound symbols are provided,
so it's ok to resolve from miniruby to simplify our build.
2022-08-04 16:29:22 +09:00
Alan Wu c69582a540 Quote $(BUILTRUBY) so paths with spaces work 2022-08-04 16:29:22 +09:00
Yuta Saito 50d81bfbc1 Link ext bundles with bundle loader option for newer ld64
ld64 shipped with Xcode 14 emits a warning when using `-undefined
dynamic_lookup`.

```
ld: warning: -undefined dynamic_lookup may not work with chained fixups
```

Actually, `-undefined dynamic_lookup` doesn't work when:

1. Link a *shared library* with the option
2. Link it with a program that uses the chained-fixup introduced from
   macOS 12 and iOS 15
because `-undefined dynamic_lookup` uses lazy-bindings and they won't be
bound while dyld fixes-up by traversing chained-fixup info.

However, we build exts as *bundles* and they are loaded only through
`dlopen`, so it's safe to use `-undefined dynamic_lookup` in theory.
So the warning produced by ld64 is false-positive, and it results
failure of option checking in configuration. Therefore, it would be an
option to ignore the warning during our configuration.

On the other hand, `-undefined dynamic_lookup` is already deprecated on
all darwin platforms except for macOS, so it's good time to get rid of
the option. ld64 also provides `-bundle_loader <executable>` option,
which allows to resolve symbols defined in the executable symtab while
linking. It behaves almost the same with `-undefined dynamic_lookup`,
but it makes the following changes:

1. Require that unresolved symbols among input objects must be defined
   in the executable.
2. Lazy symbol binding will lookup only the symtab of the bundle loader
   executable. (`-undefined dynamic_lookup` lookups all symtab as flat
   namespace)

This patch adds `-bundle_loader $(RUBY)` when non-EXTSTATIC
configuration by assuming ruby executable can be linked before building
exts.

See "New Features" subsection under "Linking" section for chained fixup
https://developer.apple.com/documentation/xcode-release-notes/xcode-13-release-notes
2022-08-04 16:29:22 +09:00
John Hawthorn 0e85586ecc Add --enable-yjit=dev_nodebug configure option 2022-07-29 16:32:14 -07:00
John Hawthorn fbd24793cb Add --enable-yjit=stats configure option 2022-07-29 16:32:14 -07:00
Jeremy Evans 2725c5dbe0 Fix invalid mkdir detection on OpenBSD
This was broken by 67e54ce408, which
resulted in " -d" being used as the mkdir_p program. I think this
is because $ac_install_sh has been set to '' at the point it is
used.

There's probably a better way to fix this, but this should allow
the OpenBSD CI to continue to work until a better fix is in place.
2022-07-08 21:08:19 -07:00
Nobuyoshi Nakada 67e54ce408
Fallback `mkdir_p` to `as_mkdir_p`
Assume `mkdir -p` to be race-free on recent systems.
And we do not provide install-sh anyway.
2022-07-07 15:06:10 +09:00
Nobuyoshi Nakada fc8020c68e
[Bug #18879] Fix macOS version detections
macOS's AvailabilityMacros.h does not contain macros for future
versions.  If a version macro is not defined, consider only earlier
versions to be targeted.
2022-06-27 01:08:46 +09:00
Nobuyoshi Nakada ec5c56412f [Feature #18839] Drop support for gcc 3 [ci skip] 2022-06-20 12:11:41 +09:00
Nobuyoshi Nakada e711711539
Show gcc version if too old, and move to GCC block [ci skip] 2022-06-18 13:40:46 +09:00
Nobuyoshi Nakada e77d2c296e
Disable maybe-uninitialized warning for gcc 4
It often shows false positive warnings (at least in 4.8).  Newer
versions work well and we can check correct warnings.
2022-06-18 13:15:02 +09:00
KJ Tsanaktsidis 05ffc037ad Disable Mach exception handlers when read barriers in place
The GC compaction mechanism implements a kind of read barrier by marking
some (OS) pages as unreadable, and installing a SIGBUS/SIGSEGV handler
to detect when they're accessed and invalidate an attempt to move the
object.

Unfortunately, when a debugger is attached to the Ruby interpreter on
Mac OS, the debugger will trap the EXC_BAD_ACCES mach exception before
the runtime can transform that into a SIGBUS signal and dispatch it.
Thus, execution gets stuck; any attempt to continue from the debugger
re-executes the line that caused the exception and no forward progress
can be made.

This makes it impossible to debug either the Ruby interpreter or a C
extension whilst compaction is in use.

To fix this, we disable the EXC_BAD_ACCESS handler when installing the
SIGBUS/SIGSEGV handlers, and re-enable them once the compaction is done.
The debugger will still trap on the attempt to read the bad page, but it
will be trapping the SIGBUS signal, rather than the EXC_BAD_ACCESS mach
exception. It's possible to continue from this in the debugger, which
invokes the signal handler and allows forward progress to be made.
2022-06-18 00:10:16 +09:00
Jeremiah Gowdy 1dfe007e16 Update configure.ac
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-06-17 11:58:10 +09:00
Jeremiah Gowdy f3b54d5fc2 Add branch protection to aarch64 targets 2022-06-17 11:58:10 +09:00
Takashi Kokubun f8502a2699
Drop MinGW support of MJIT (#6012)
[Feature #18824]
2022-06-13 09:28:28 -07:00
Nobuyoshi Nakada a56a7119ac
Remove useless assignment always overridden 2022-06-06 11:30:26 +09:00
nick evans d8790ecd04
Export RbConfig::CONFIG["COROUTINE_TYPE"]
THREAD_MODEL is exported already, so this matches that.  Exporting this
is simpler than inspecting configure_args and arch and matching that up
with a specific configure.ac.

Fix GH-5976
2022-06-06 11:30:13 +09:00
Nobuyoshi Nakada 218e8bdcb0
Disable usage of TLS unless available
Thread-local storage is supported since Mac OS X 10.7.  Enable TLS
only when the target version is enough.
2022-05-22 16:49:48 +09:00
Nobuyoshi Nakada e79983a448
Check if thread-local storage is supported on macOS
We need thread-local storage on Clang, since 319afed20f.
2022-05-22 15:26:42 +09:00
Sergey Fedorov 539459abda
Ruby31: add support for Darwin ppc/ppc64 (#5927)
* add coroutines for ppc & ppc64

* fix universal coroutine to include ppc & ppc64

* add powerpc*-darwin to configure.ac

* fix thread_pthread for older systems
2022-05-22 15:02:03 +12:00
Jun Aruga 019cbded90 mkmf: Add a configure option to set verbose mode (V=1 or 0) in mkmf.rb.
Note this change is only for `configure.ac`, not for Windows using
`win32/configure.bat`.

```
$ ./configure --help | grep mkmf
  --enable-mkmf-verbose   enable verbose in mkmf
```

Run the following command to enable the mkmf verbose mode.

```
$ ./configure --enable-mkmf-verbose
$ grep MKMF_VERBOSE config.status
S["MKMF_VERBOSE"]="1"
```

In this mkmf verbose mode, when compiling a native extension, the
`rake compile` prints the compiling commands such as
"gcc -I. <...> path/to/file" instead of "compiling path/to/file".

```
$ git clone https://github.com/deivid-rodriguez/byebug.git
$ cd byebug
$ bundle install --standalone
$ bundle exec rake compile
...
gcc -I. <...> path/to/file
...
```
2022-05-12 12:36:10 +02:00
Nobuyoshi Nakada c7d2247e35
Honor --with-thread option to enable pthread 2022-05-10 09:24:28 +09:00
Aaron Patterson 907b31d7b9 Don't set LDFLAGS by default
This fixes a bug where Ruby on macOS running on ARM would try to look in
`/usr/local/lib` for things to link against, but the libraries in that
directory are from the x86 installation of Homebrew

[ruby-core:108424]
2022-04-28 15:14:45 -07:00
Alan Wu f90549cd38 Rust YJIT
In December 2021, we opened an [issue] to solicit feedback regarding the
porting of the YJIT codebase from C99 to Rust. There were some
reservations, but this project was given the go ahead by Ruby core
developers and Matz. Since then, we have successfully completed the port
of YJIT to Rust.

The new Rust version of YJIT has reached parity with the C version, in
that it passes all the CRuby tests, is able to run all of the YJIT
benchmarks, and performs similarly to the C version (because it works
the same way and largely generates the same machine code). We've even
incorporated some design improvements, such as a more fine-grained
constant invalidation mechanism which we expect will make a big
difference in Ruby on Rails applications.

Because we want to be careful, YJIT is guarded behind a configure
option:

```shell
./configure --enable-yjit # Build YJIT in release mode
./configure --enable-yjit=dev # Build YJIT in dev/debug mode
```

By default, YJIT does not get compiled and cargo/rustc is not required.
If YJIT is built in dev mode, then `cargo` is used to fetch development
dependencies, but when building in release, `cargo` is not required,
only `rustc`. At the moment YJIT requires Rust 1.60.0 or newer.

The YJIT command-line options remain mostly unchanged, and more details
about the build process are documented in `doc/yjit/yjit.md`.

The CI tests have been updated and do not take any more resources than
before.

The development history of the Rust port is available at the following
commit for interested parties:
1fd9573d8b

Our hope is that Rust YJIT will be compiled and included as a part of
system packages and compiled binaries of the Ruby 3.2 release. We do not
anticipate any major problems as Rust is well supported on every
platform which YJIT supports, but to make sure that this process works
smoothly, we would like to reach out to those who take care of building
systems packages before the 3.2 release is shipped and resolve any
issues that may come up.

[issue]: https://bugs.ruby-lang.org/issues/18481

Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
Co-authored-by: Noah Gibbs <the.codefolio.guy@gmail.com>
Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2022-04-27 11:00:22 -04:00
S-H-GAMELINKS 5b467400d2 [DOC]Some link prefix replace 2022-04-09 17:43:46 +09:00
S-H-GAMELINKS bff12e1a9a [DOC] Fix comment links 2022-04-07 10:37:52 +09:00
Alan Wu 2222032979
Remove dependency on libcapstone
We have received reports of build failures due to this configuration
check modifying compile flags. Since only YJIT devs use this library
we can remove it to make Ruby easier to build for users.

See: https://github.com/rbenv/ruby-build/discussions/1933
2022-03-31 17:26:28 -04:00
Nobuyoshi Nakada 2cb3efffcf
Extract RUBY_REQUIRE_FUNCS 2022-03-28 16:56:15 +09:00
Nobuyoshi Nakada 7470780058 Check if `__assume` is supported 2022-02-19 23:32:52 +09:00
Nobuyoshi Nakada 131154f878 Define `HAVE___BUILTIN_UNREACHABLE` instead of `UNREACHABLE`
`UNREACHABLE` in ruby/internal/has/builtin.h is only used as just
a flag now, and redefined in ruby/backward/2/assume.h then.
2022-02-19 23:32:52 +09:00
Nobuyoshi Nakada 4113862c00 Do not search for commands with double tool prefixes [Bug #18504]
The `CC` found by `AC_CHECK_TOOL` is prefixed by the host triplet
when cross compiling.  To search for commands with `AC_CHECK_TOOL`
based on that `CC` means to search also doubly prefixed names.
2022-02-17 22:47:02 +09:00
Nobuyoshi Nakada bffd6cbd97
Check if `execv` is available for ruby/missing.h
As MinGW has the declaration, the `dllimport` attribute difference
is warned when compiling missing/*.c without including ruby/win32.h.

```
../src/include/ruby/missing.h:316:17: warning: 'execv' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  316 | RUBY_EXTERN int execv(const char *, char *const []);
      |                 ^~~~~
```
2022-01-26 18:23:51 +09:00
Nobuyoshi Nakada 4010cbfe35
Use the prefixed pkg-config command 2022-01-26 15:56:22 +09:00
Nobuyoshi Nakada 2c25427496
GCC provides -Wdiv-by-zero 2022-01-22 20:09:56 +09:00
Nobuyoshi Nakada 71bc999009
MinGW also uses `rb_w32_shutdown`
Winsock's `shutdown` is incompatible with the other platforms.
And autoconf fails to detect WINAPI functions on 32bit Windows,
probably due to the argument size suffixes.
2022-01-20 01:18:49 +09:00
Nobuyoshi Nakada 5646f4b67b
Fix a missing comma 2022-01-19 14:46:27 +09:00
Yuta Saito bb2228817f [wasm] configure.ac: disable mjit on wasi by default 2022-01-19 11:19:06 +09:00
Yuta Saito df31fa4a51 [wasm] configure.ac: don't require dup and dup2 only for wasi 2022-01-19 11:19:06 +09:00
Yuta Saito 3794ef6f01 configure.ac: stop overwriting cc wrapper by darwin-cc everytime 2022-01-19 11:19:06 +09:00
Yuta Saito a4b73f1ba8 [wasm] add coroutine/asyncify implementation
set the default coroutine_type as asyncify when wasi
2022-01-19 11:19:06 +09:00
Yuta Saito 7ee786388a [wasm] wasm/missing.{c,h}: add missing libc stubs for wasi-libc 2022-01-19 11:19:06 +09:00
Yuta Saito 65f95f26ff [wasm] add asyncify based setjmp, fiber, register scan emulation
configure.ac: setup build tools and register objects

main.c: wrap main with rb_wasm_rt_start to handle asyncify unwinds

tool/m4/ruby_wasm_tools.m4: setup default command based on WASI_SDK_PATH
environment variable. checks wasm-opt which is used for asyncify.

tool/wasm-clangw wasm/wasm-opt: a clang wrapper which replaces real
wasm-opt with do-nothing wasm-opt to avoid misoptimization before
asyncify. asyncify is performed at POSTLINK, but clang linker driver
tries to run optimization by wasm-opt unconditionally. inlining pass
at wasm level breaks asyncify's assumption, so should not optimize
before POSTLIK.

wasm/GNUmakefile.in: wasm specific rules to compile objects
2022-01-19 11:19:06 +09:00
Yuta Saito e41b121e94 [wasm] configure.ac: setup platform specific libraries
These flags are very wasi-libc version specific, so updating wasi-libc
may break the build. But supporting multiple wasi-libc versions in ruby
doesn't have much benefit because wasi-libc is not installed in most
systems.
2022-01-19 11:19:06 +09:00
Yuta Saito 8a50a6b6f9 [wasm] configure.ac: disable stack-protector
clang does not yet support stack-protector for wasm
2022-01-19 11:19:06 +09:00
Peter Zhu ffda21b7ba [Feature #18491] Drop support for HP-UX
IA64 support was dropped in ticket #15894, so we can drop support for
HP-UX.
2022-01-18 09:52:15 -05:00
Yuta Saito ae51f304d2 io_buffer.c: use mremap based resizing only when mremap available
some libc implementations (e.g. wasi-libc) define MREMAP_MAYMOVE, but
don't have mremap itself, so guard the use of mremap by HAVE_MREMAP
2022-01-07 02:13:19 +09:00
Nobuyoshi Nakada c87c027f18 configure.in: unexpand exec_prefix in includedir
Replace `exec_prefix` in includedir as well as bindir, libdir, and
so on. [Bug #18373]
2021-12-24 19:11:10 +09:00
Nobuyoshi Nakada ec878dac90
Move -ljemalloc to DLDLIBS [Bug #18391]
Set the alternative memory management library only as a platform
specific library, without other libraries.
2021-12-07 15:20:02 +09:00
Naohisa Goto e59f3054c3 Delete #if line during checking madvise() on Solaris
The madvise() declaration should always be compiled on Solaris
to check whether the declaration is good on the environment.
For the purpose, the #if line is unnecessary.
(There was also a trivial typo that the #if was not closed
by #endif and the check always failed with preprocessor error.)
2021-11-30 16:39:31 +09:00
Nobuyoshi Nakada 316caf6b39
Enable load-relative on Solaris 2021-11-30 12:40:02 +09:00
Nobuyoshi Nakada f379748e80
Cache wheather madvise declaration is needed on Solaris 2021-11-30 11:12:21 +09:00
Nobuyoshi Nakada 12fbdf4d4e
Fix conflicting declaration on Solaris
SunC
```
"cont.c", line 24: identifier redeclared: madvise
	current : function(pointer to char, unsigned int, int) returning int
	previous: function(pointer to void, unsigned int, int) returning int : "/usr/include/sys/mman.h", line 232
```

GCC
```
cont.c:24:12: error: conflicting types for 'madvise'
   24 | extern int madvise(caddr_t, size_t, int);
      |            ^~~~~~~
In file included from cont.c:16:
/usr/include/sys/mman.h:232:12: note: previous declaration of 'madvise' was here
  232 | extern int madvise(void *, size_t, int);
      |            ^~~~~~~
```
2021-11-30 09:10:58 +09:00
Naohisa Goto 8287d2f23c Workaround for implicit declaration of function 'madvise' on Solaris
On Solaris, madvise(3C) is NOT defined for SUS (XPG4v2) or later,
but MADV_* macros are defined when __EXTENSIONS__ is defined.
This may cause compile error on Solaris 10 with GCC when
"-Werror=implicit-function-declaration" and "-D_XOPEN_SOURCE=600"
are added by configure.
2021-11-30 00:03:04 +09:00
Yusuke Endoh 9fc7ea64a1 configure.ac: don't use shutdown on emscripten
... to absorb a change on Ubuntu 21.10
2021-11-03 14:00:51 +09:00
Yuta Saito ccda26efe7 Split thread-model config into another ac file
This is a first step to allow the thread-model implementation to be
switched by configure's option
2021-10-30 10:18:33 +09:00
Nobuyoshi Nakada 5ff47e0c8a Check old-style definitions 2021-10-27 16:28:10 +09:00
Alan Wu 28632ea7ba Mention YJIT in Capstone autoconf check 2021-10-20 18:19:43 -04:00
Aaron Patterson 7efde1bfb4 conditionally add libcapstone 2021-10-20 18:19:27 -04:00
Aaron Patterson e427fdff0a Directly link libcapstone for easier development
This lets us use libcapstone directly from miniruby so we don't need a
Ruby Gem to to dev work.

Example usage:

```ruby
def foo(x)
  if x < 1
    "wow"
  else
    "neat"
  end
end

iseq = RubyVM::InstructionSequence.of(method(:foo))
puts UJIT.disasm(iseq)
100.times { foo 1 }
puts UJIT.disasm(iseq)
```

Then in the terminal

```
$ ./miniruby test.rb

== disasm: #<ISeq:foo@test.rb:1 (1,0)-(7,3)> (catch: FALSE)
local table (size: 1, argc: 1 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] x@0<Arg>
0000 getlocal_WC_0                          x@0                       (   2)[LiCa]
0002 putobject_INT2FIX_1_
0003 opt_lt                                 <calldata!mid:<, argc:1, ARGS_SIMPLE>
0005 branchunless                           10
0007 putstring                              "wow"                     (   3)[Li]
0009 leave                                                            (   7)[Re]
0010 putstring                              "neat"                    (   5)[Li]
0012 leave                                                            (   7)[Re]

== ISEQ RANGE: 10 -> 10 ========================================================
        0x0:    movabs  rax, 0x7fe816e2d1a0
        0xa:    mov     qword ptr [rdi], rax
        0xd:    mov     r8, rax
        0x10:   mov     r9, rax
        0x13:   mov     r11, r12
        0x16:   jmp     qword ptr [rax]
== ISEQ RANGE: 0 -> 7 ==========================================================
        0x0:    mov     rax, qword ptr [rdi + 0x20]
        0x4:    mov     rax, qword ptr [rax - 0x18]
        0x8:    mov     qword ptr [rdx], rax
        0xb:    mov     qword ptr [rdx + 8], 3
        0x13:   movabs  rax, 0x7fe817808200
        0x1d:   test    byte ptr [rax + 0x3e6], 1
        0x24:   jne     0x3ffff7b
        0x2a:   test    byte ptr [rdx], 1
        0x2d:   je      0x3ffff7b
        0x33:   test    byte ptr [rdx + 8], 1
        0x37:   je      0x3ffff7b
        0x3d:   mov     rax, qword ptr [rdx]
        0x40:   cmp     rax, qword ptr [rdx + 8]
        0x44:   movabs  rax, 0
        0x4e:   movabs  rcx, 0x14
        0x58:   cmovl   rax, rcx
        0x5c:   mov     qword ptr [rdx], rax
        0x5f:   test    qword ptr [rdx], -9
        0x66:   jne     0x3ffffd5
```

Make sure to `brew install pkg-config capstone`
2021-10-20 18:19:27 -04:00
David CARLIER dfe944bfbe haiku configure fix (again). 2021-10-18 17:40:19 +09:00
David CARLIER 1831693c1f haiku build update stack overflow check in libroot (haiku's libc) now 2021-10-17 14:00:59 +09:00
Jeremy Evans 06c3e80611 Do not allow configuration where neither static or shared library is installed
Fixes [Bug #18000]
2021-10-08 14:01:54 -09:00
Nobuyoshi Nakada e0ef4899f3 [Win32] Prefer Cryptography Next Generation API
[BCryptGenRandom] is available since Windows Vista / Windows
Server 2008.

Regarding [CryptGenRandom]:
> This API is deprecated. New and existing software should start
> using Cryptography Next Generation APIs. Microsoft may remove
> this API in future releases.

[BCryptGenRandom]: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
[CryptGenRandom]: https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptgenrandom
2021-10-02 21:22:33 +09:00
Nobuyoshi Nakada 0ad3ed5e0e
Checks for CPU specific header on universal build 2021-10-01 20:30:10 +09:00
Nobuyoshi Nakada ca3cc677b3
Define ACTION-IF-UNIVERSAL of `AC_C_BIGENDIAN` [Bug #18156]
As we do not use config.h.in, just define the helper macro
instead.
2021-10-01 10:56:11 +09:00
Nobuyoshi Nakada 912a8dcfc5
Needs `AC_PROG_CC`
Although `AC_PROG_CC_C99` has been obsolete, `AC_PROG_CC` is not
and the latter is necessary not to make C++ compiler mandatory.
2021-09-30 19:22:08 +09:00
Lars Kanis 576b2e64cd MINGW-UCRT: Set CONFIG['arch'] and RUBY_PLATFORM to "x64-mingw-ucrt"
This allows easy differentiation between ABI incompatible platforms like MSWIN64 and MSVCRT-based MINGW32.
This also implicates a distinct rubygem platform which is also "x64-mingw-ucrt".

Although the term "mingw32" is the OS-part for 64 bit systems as well, the "32" is misleading and confusing for many users.
Therefore the new platform string drops the "32" from the OS part to just "mingw".
This conforms to the common practice of windows platform testing per RUBY_PLATFORM=~/mswin|mingw/ .
2021-09-20 00:15:30 +09:00
xtkoba (Tee KOBAYASHI) 637d7288f3 MINGW: More permissive pattern matching for coroutine
Pattern matching for target_os in configure script should be permissive if we consider suffixing something onto "mingw32".
2021-09-20 00:15:30 +09:00
xtkoba (Tee KOBAYASHI) 8bda512878 MINGW: set rb_cv_msvcrt=ucrt and RT_VER=140 when UCRT is used 2021-09-20 00:15:30 +09:00
DC a8fe7c9e2a coroutine enables assembly version for dragonflybsd. 2021-09-13 08:12:15 +12:00
Nobuyoshi Nakada b76ad15ed0
Remove stale DLEXT2
Actually disabled at 181a3a2af5 in
2004,  it has remained in config.status and been carried over to
rbconfig.rb.
2021-09-10 14:51:56 +09:00
Nobuyoshi Nakada 7487371eeb
Make ruby.pc from make
Expand variables undefined in configure.ac, RUBY_RELEASE_DATE and
so on.
2021-08-29 14:08:53 +09:00
Nobuyoshi Nakada 623736ae7f
Move DEFFILE to EXTDLDFLAGS
So that it is no longer needed in ruby.pc.in.
2021-08-29 13:04:42 +09:00
Nobuyoshi Nakada 80c1faf076
Use C99-defined signbit macro 2021-08-27 12:42:23 +09:00
Nobuyoshi Nakada 04be8e84db
Use C99-defined macros to classify a floating-point number 2021-08-27 12:41:30 +09:00
David Carlier 8d2af51a78 netbsd coroutine uses assembly instead and little build fix. 2021-08-24 10:52:04 +09:00
Nobuyoshi Nakada 5087a6a924
Fix COROUTINE_SRC on emscripten
Select the C source if exists, otherwise the assembler source,
instead of selecting by the coroutine type.
2021-08-16 13:45:30 +09:00
DC f8f6d9895d coroutine use asm version for handful of architectures for freebsd. 2021-08-16 12:06:46 +12:00
Nobuyoshi Nakada 372d94b6ba
Shared libruby also needs MAINLIBS for jemalloc 2021-07-07 23:40:04 +09:00
Nobuyoshi Nakada e8d9539373
Refactor --with-jemalloc option
Find jemalloc header first, then using the found header, try [with
mangle, without mangle] x [no more additional libraries, adding
jemalloc] combination.
2021-07-07 23:40:04 +09:00
卜部昌平 82d425515d comment about the situation [ci skip] 2021-07-07 20:31:20 +09:00
卜部昌平 737e4432b9 configure: add -Wl,--no-as-needed
It is reported that combination of `--enable-shared --with-jemalloc`
breaks on Debian bullseye (testig).  Deeper investigation revealed that
this system's `ld(1)` is patched, to turn `ld --as-needed` on by
default.

This linker flag strips "unnecessary" library dependencies from an
executable.  In case of `ruby(1)` (of `--enable-shared`), because
everything is in `libruby.so`, the binary itself doesn't include any
calls to `malloc(3)` at all.  So in spite of our explicit `-ljemalloc`
flag, it is ignored.  Libc's one is chosen instead.

This is not what we want.  Let's force our `ruby(1)` link what we want.

Fixes https://github.com/ruby/ruby/pull/4627

The author would like to acknowledge
Akihiko Odaki <akihiko.odaki@gmail.com> for their contributions.
2021-07-07 20:31:20 +09:00
Nobuyoshi Nakada 91258ed449
Enable libruby-relative on FreeBSD 2021-07-06 21:26:14 +09:00
Nobuyoshi Nakada 166d148355
Fix check for malloc_conf when no library is required 2021-07-06 21:02:41 +09:00
Nobuyoshi Nakada c5e6fa4853
Moved native coroutine type checking message
Not to be interleaved by fallback checking messages
2021-07-06 21:02:40 +09:00
Samuel Williams 42130a64f0
Replace copy coroutine with pthread implementation. 2021-07-01 11:23:03 +12:00
Nobuyoshi Nakada 627aafac86
Remove also debug symbol directory at clean on macOS 2021-06-24 17:04:42 +09:00
Nobuyoshi Nakada 4b28fea6ee
Run ifchange with shell explicitly, workaround of noexec mount 2021-06-22 09:46:40 +09:00
Nobuyoshi Nakada c2d9967f78 Configure ioctl request argument type [Bug #17759] 2021-06-16 13:17:19 +09:00
卜部昌平 90cad6e147 prefer cc/gcc over clang on solaris
requested by tankf33der at https://bugs.ruby-lang.org/issues/17949#change-92430
2021-06-14 22:37:17 +09:00
Nobuyoshi Nakada 7cf90f99f5
Refix PAGE_SIZE
* honor actually used headers
* include sys/user.h only when `PAGE_SIZE` is not defined
2021-05-14 09:33:20 +09:00
John Hawthorn 0aa4ca1477 Fix compilation with jemalloc on macos
On darwin we avoid including sys/user.h to avoid a conflict. Previously
we still ended up with PAGE_SIZE being defined because the headers for
system malloc define it. However, when compiling with jemalloc nothing
would define PAGE_SIZE.

This commit changes configure.ac so that we never use the PAGE_SIZE
constant on darwin and to always use the sysconf fallback.
2021-05-13 11:14:30 -04:00
Nobuyoshi Nakada 2d67027448 Removed missing/dup2.c
This function should be always available, as POSIX-compliant or
Windows platform are required since 1.9.  Also the code in this
file is MT-unsafe.
2021-05-10 15:59:23 +09:00
Nobuyoshi Nakada a1fdc5f71c
Check only whether PAGE_SIZE is compile-time const 2021-05-06 11:30:37 +09:00
Nobuyoshi Nakada 921d8ac99d
Get rid of including sys/user.h on macOS
LIST_HEAD in ccan/list conflicts with sys/queue.h.

```
./ccan/list/list.h:75:9: warning: 'LIST_HEAD' macro redefined [-Wmacro-redefined]
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/queue.h:465:9: note: previous definition is here
        ^
```
2021-05-06 09:39:47 +09:00
Peter Zhu 23a98237df Fix PAGE_SIZE macro detection in autoconf
The current fix for PAGE_SIZE macro detection in autoconf does not work
correctly. I see the following output with running configure on Linux:

```
checking PAGE_SIZE is defined... no
```

Linux has PAGE_SIZE macro. This is happening because the macro exists in
sys/user.h and not in the malloc headers.
2021-05-05 15:31:30 -04:00
Nobuyoshi Nakada 3d5b6ddff8
Fix compilation on M1 Mac
As PAGE_SIZE may not be a preprocessor constant, dispatch at
runtime in that case.
2021-05-05 23:54:36 +09:00
Yusuke Endoh e71c9ca529 configure.ac: check if __builtin_expect is available or not
include/ruby/internal/has/builtin.h uses HAVE_BUILTIN___BUILTIN_EXPECT
for icc but previously it was not defined.

This is a follow up of 8b32de2ec9 and this
will fix the following failures:

http://rubyci.s3.amazonaws.com/icc-x64/ruby-master/log/20210505T030003Z.fail.html.gz
```
  1) Failure:
TestMkmf::TestConvertible#test_typeof_builtin [/home/chkbuild/chkbuild/tmp/build/20210505T030003Z/ruby/test/mkmf/test_convertible.rb:9]:
convertible_int: checking for convertible type of short... -------------------- short

--------------------

convertible_int: checking for convertible type of int... -------------------- int

--------------------

convertible_int: checking for convertible type of long... -------------------- long

--------------------

convertible_int: checking for convertible type of signed short... -------------------- failed

"icc -std=gnu99 -o conftest -I. -I/home/chkbuild/chkbuild/tmp/build/20210505T030003Z/ruby/.ext/include/x86_64-linux -I/home/chkbuild/chkbuild/tmp/build/20210505T030003Z/ruby/include -I./test    -O3 -ggdb -Wall -Wextra -Wdeprecated-declarations -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-unused-parameter -Wunused-variable -diag-disable=175,188,1684,2259,2312 -Wextra-tokens -Wundef conftest.c  -L. -L/home/chkbuild/chkbuild/tmp/build/20210505T030003Z/ruby -Wl,-rpath,/home/chkbuild/chkbuild/tmp/build/20210505T030003Z/ruby -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic     -Wl,-rpath,/home/chkbuild/chkbuild/tmp/build/20210505T030003Z/lib -L/home/chkbuild/chkbuild/tmp/build/20210505T030003Z/lib -lruby-static -lz -lpthread -lrt -lrt -ldl -lcrypt -lm   -lm   -lc"
In file included from /home/chkbuild/chkbuild/tmp/build/20210505T030003Z/ruby/include/ruby/defines.h(72),
                 from /home/chkbuild/chkbuild/tmp/build/20210505T030003Z/ruby/include/ruby/ruby.h(23),
                 from /home/chkbuild/chkbuild/tmp/build/20210505T030003Z/ruby/include/ruby.h(39),
                 from conftest.c(1):
/home/chkbuild/chkbuild/tmp/build/20210505T030003Z/ruby/include/ruby/backward/2/assume.h(34): warning #193: zero used for undefined preprocessing identifier "HAVE_BUILTIN___BUILTIN_EXPECT"
  #if RBIMPL_HAS_BUILTIN(__builtin_expect)

...
```
2021-05-05 12:58:12 +09:00
Nobuyoshi Nakada 5bde2e61db Workaround for gcc-4 bug
False positive `-Wundef` in `#elif` after `#if defined`.
2021-05-05 10:10:59 +09:00
Benoit Daloze 8b32de2ec9 Add -Werror=undef to default warnflags for core
* See [Feature #17752]
* For external extensions it's transformed to just warn and not error (-Wundef)
  like other other -Werror in warnflags.
2021-05-04 14:56:55 +02:00
Nobuyoshi Nakada 1f56238032
Remove comments in tool/m4 from the generated configure 2021-04-17 19:14:21 +09:00
Nobuyoshi Nakada 17c3014bb7
Prefer positive condition to double negative
Autoconf 2.70 seems to omit the check for the given CC,
`AC_COMPILE_IFELSE` does not know which is the cause of the
failure.
2021-04-17 19:08:53 +09:00
Nobuyoshi Nakada a5688b5ce6
Support non-standard `struct stat` [Bug #17793]
On 32-bit Android:
* `st_dev`/`st_rdev` are not `dev_t`
* `st_mode` is not `mode_t`
2021-04-12 15:32:49 +09:00
Nobuyoshi Nakada 4a6c7f8696 configure: always check for atomic/sync builtins [Bug #17787]
Non-gcc compilers tend to have this intrinsic these days, e.g. xlc
has `__sync` builtins.
2021-04-10 16:05:01 +09:00
Nobuyoshi Nakada 8b7cab70eb configure: try `-fdeclspec` option by linking [Bug #17787]
A workaround for `-f` option of AIX xlc compiler which works only
on linking.
2021-04-10 16:05:01 +09:00
Kazuhiro NISHIYAMA 9713acd731
Fix `coroutine_type` variable name 2021-03-30 20:58:34 +09:00
Samuel Williams b507f65d44 Support for native riscv64 coroutines. 2021-03-30 19:23:17 +13:00
Nobuyoshi Nakada 1f08b0d18d
Removed dln_a_out
a.out format is considered extinct nowadays.
2021-03-24 20:13:55 +09:00
Yusuke Endoh 1c6f5ca4d4 configure.ac: enable FORCE_FILESYSTEM for Emscripten 2021-03-20 03:04:55 +09:00
Rick Mark dc7044eb48
Remove unneeded dependencies on macOS [Feature #17730] 2021-03-19 15:27:42 +09:00
Nobuyoshi Nakada 4ea96f1d4f
Use CommonRandom if available 2021-03-19 15:23:03 +09:00
Yusuke Endoh e79b42c9b2 configure.ac: don't use pthread_sigmask in emscripten 2021-03-19 12:32:33 +09:00
Yusuke Endoh d97ed004e8 configure.ac: avoid spaces in a LDFLAGS option
Seems like it confuses "make ruby" for emscripten.
2021-03-19 12:30:59 +09:00
卜部昌平 f9e4378299
get rid of aclocal (#4280) 2021-03-17 18:52:53 +09:00
Nobuyoshi Nakada ea39955e23
Removed a duplicate setting for mingw 2021-03-12 15:51:29 +09:00
Nobuyoshi Nakada 4c80b9d063
Fix `coroutine_type` variable name 2021-03-10 22:13:06 +09:00
Nobuyoshi Nakada f0b3700ddc
Given argument does not need to cache 2021-03-09 23:05:24 +09:00
Nobuyoshi Nakada 5f821ee977
Recheck ucontext functions to make reconfig stable 2021-03-09 20:36:15 +09:00
Peter Zhu 0bd1bc559f Don't use mmap on platforms that have large OS page sizes 2021-03-02 10:04:49 -08:00
Peter Zhu 1e13548953 Use mmap for allocating heap pages 2021-02-25 11:01:50 -08:00
Aaron Patterson 08d5db4064
Reverting PR #4221
It seems this breaks tests on Solaris, so I'm reverting it until we
figure out the right fix.

  http://rubyci.s3.amazonaws.com/solaris11-sunc/ruby-master/log/20210224T210007Z.fail.html.gz
2021-02-24 13:44:10 -08:00
Peter Zhu 785f5eb8f0 Use mmap for allocating heap pages 2021-02-24 12:25:30 -08:00
David Carlier dfd029c962 supports for stack protection for haiku. 2021-02-15 17:16:14 +09:00
Andrew Aladjev 3c593f28ed
Fixed default coroutine selection for musl. 2021-02-09 18:48:03 +13:00
Nobuyoshi Nakada 0acc05caf7
Add -fdeclspec to CFLAGS instead of CC 2021-02-05 12:34:17 +09:00
Nobuyoshi Nakada 49918b3984
MSys is a variant of Cygwin 2021-01-31 14:27:15 +09:00
Nobuyoshi Nakada c736714de1
Clear unexpanded `mjit_std_cflag` 2021-01-27 15:00:19 +09:00
Nobuyoshi Nakada 0d5a4d6d49
Disable fast-math
As `RUBY_TRY_CFLAGS` restores `CFLAGS`, appending to the variable
in its block has no effect.
2021-01-27 14:50:27 +09:00
Yusuke Endoh 62283f7a7a coroutine/emscripten/: Experimentally support emscripten fiber API 2021-01-23 18:56:06 +09:00
Yusuke Endoh f12c33b611 configure.ac: Add some compiler options for emscripten
"-lc" and "-s ALLOW_MEMORY_GROWTH=1" are needed
2021-01-23 16:07:41 +09:00
Yusuke Endoh 1dfddac393 configure.ac: Stop -fstack-protector on emscripten build 2021-01-23 10:11:50 +09:00
Nobuyoshi Nakada 07b4b1b1cb
Support coroutine on universal binary 2021-01-22 23:41:52 +09:00
Nobuyoshi Nakada c3244a3574
Do not set target_alias if unset 2021-01-22 22:29:17 +09:00
Nobuyoshi Nakada c8121b2e3d
Adjust CPU name as arm64-darwin
config.sub replaces arm64 with aarch64.
2021-01-22 18:37:31 +09:00
Nobuyoshi Nakada 48bb0329eb
Revert AC_PROG_CC_C99 for -std=gnu99 option to gcc 4.8 2021-01-18 16:22:17 +09:00
Nobuyoshi Nakada c32375883a
Update for autoconf 2.70 2021-01-18 16:22:17 +09:00
Nobuyoshi Nakada a3851d97ed
Removed unused AC_CHECKING 2021-01-18 15:33:10 +09:00
Kazuhiro NISHIYAMA 6abf393e8f
OpenBSD has getentropy, but no sys/random.h
https://man.openbsd.org/getentropy

Try to fix https://rubyci.s3.amazonaws.com/openbsd-current/ruby-master/log/20210118T023008Z.fail.html.gz
```
compiling random.c
random.c:53:11: fatal error: 'sys/random.h' file not found
# include <sys/random.h>
          ^~~~~~~~~~~~~~
1 error generated.
```
2021-01-18 12:43:05 +09:00
David CARLIER 54c91185c9 random generator update for Mac proposal
using getentropy for seeding, reading 256 bytes at a time to avoid
 the EIO errno since this is the maximum.
2021-01-17 18:48:48 +09:00
Yusuke Endoh b9c1b3f8d8 configure.ac: disable using __builtin_setjmp on ARM Android
A patch from Tee KOBAYASHI <xtkoba+ruby@gmail.com>. [Bug #17511]
2021-01-05 13:59:03 +09:00
Yusuke Endoh 449ef72cb9 configure.ac: Stop auto-detection of __ANDROID_API__ when cross-compiling
A patch from Tee KOBAYASHI <xtkoba+ruby@gmail.com>. [Bug #17491]
2021-01-05 10:16:05 +09:00
TAKANO Mitsuhiro 78677f105d
Disable DTrace in FreeBSD (#3999)
The latest ruby cannot compile with FreeBSD Dtrace enabled.
2020-12-25 12:06:46 +09:00
Yusuke Endoh c64a067d05 configure.ac: Make it possible to build on Android Termux
The recent Termux's clang predefines `__ANDROID_API__` as a fixed number
24. However, when it is lower to the current device version, some
functions that "configure" detemines available are not declared
correctly in the header files.

This change forces to overwrite the predefined `__ANDROID_API__` macro
with the current device version.

ref: https://github.com/termux/termux-packages/issues/6176
2020-12-25 00:06:16 +09:00
Naohisa Goto 84eebb3c9e On Solaris, _XOPEN_SOURCE should be undefined for C++ sources. 2020-12-21 23:42:34 +09:00
卜部昌平 ccc828f499 configure.ac: avoid squashing CXX=g++
We are discussing this issue at [Bug #17337] but in the meantime, leave
this questionable autoconf glitch as-is to save sassc and eventmachine.
2020-12-16 08:47:49 +09:00
Zoltán Mizsei 9542321584
Haiku: disable stack-protector 2020-12-15 23:12:31 +09:00
Zoltán Mizsei 4d43ac2fb9
Add Haiku to the context support list 2020-12-15 23:12:28 +09:00
Nobuyoshi Nakada 4d2ad8d737
Removed obsolete autoconf checks
Use regular `AC_CHECK_MEMBERS` instead of:
* `AC_STRUCT_ST_BLKSIZE`
* `AC_STRUCT_ST_BLOCKS`
* `AC_STRUCT_ST_RDEV`
2020-12-12 17:23:44 +09:00
Nobuyoshi Nakada 0df67a4695 Signal handler type should be void 2020-12-12 17:02:42 +09:00
Nobuyoshi Nakada 21c5726418 Omit checks for C89 standard or later
Now we require C99, these features available of course.

* prototypes
* stdarg prototypes
* token pasting
* stringization
* string literal concatenation
2020-12-12 17:02:42 +09:00
Yusuke Endoh 8c5ec10038 Link zlib always if available
Major Linux distribution packages including Debian, Ubuntu, and Fedora
use `--compress-debug-sections=no` to build ruby, and then extract and
compress debug symbols as separate files. However, the configure option
makes ruby not link zlib, thus the generated binary cannot uncompress
the compressed separate debug symbol files, and fails to show C level
backtrace when a critical error like segfault occurs.

This change makes ruby always link zlib if it is available so that it
can show C level backtrace correctly.

Related: Debian packages require https://github.com/ruby/ruby/pull/3627
to load debug symbol files.
2020-12-11 14:08:23 +09:00
Masaki Matsushita 5d8bcc4870 Revert getaddrinfo_a()
getaddrinfo_a() gets stuck after fork().
To avoid this, we need 1 second sleep to wait for internal
worker threads of getaddrinfo_a() to be finished, but that is unacceptable.

[Bug #17220] [Feature #17134] [Feature #17187]
2020-12-07 13:33:53 +09:00
Masaki Matsushita 94d49ed31c Add a hook before fork() for getaddrinfo_a()
We need stop worker threads in getaddrinfo_a() before fork().
This change adds a hook before fork() that cancel all outstanding requests
and wait for all ongoing requests. Then, it waits for all worker
threads to be finished.

Fixes [Bug #17220]
2020-12-04 23:31:51 +09:00
Yusuke Endoh 5d8fe1267d configure.ac: Check x86intrin.h only when the target CPU is x86
The check output a warning on M1 Mac mini

http://rubyci.s3.amazonaws.com/osx1100arm/ruby-master/log/20201127T074507Z.log.html.gz
```
checking x86intrin.h usability... no
checking x86intrin.h presence... yes
configure: WARNING: x86intrin.h: present but cannot be compiled
configure: WARNING: x86intrin.h:     check for missing prerequisite headers?
configure: WARNING: x86intrin.h: see the Autoconf documentation
configure: WARNING: x86intrin.h:     section "Present But Cannot Be Compiled"
configure: WARNING: x86intrin.h: proceeding with the compiler's result
checking for x86intrin.h... no
```
2020-11-27 19:53:21 +09:00
Nobuyoshi Nakada 2939c57ca7
Check if _FORTIFY_SOURCE really works
i686-pc-cygwin gcc 6.4.0 seems broken around ssp.h, when compiling
with both of optimization and _FORTIFY_SOURCE.
2020-11-23 17:56:23 +09:00
Nobuyoshi Nakada 43a9a974e2
[Bug #17021] Make host_* values consistent with target_* 2020-11-21 23:21:52 +09:00
Sergei Trofimovich fcc88da5eb configure.ac: fix for upcoming autoconf-2.70
The failure initially noticed on `autoconf-2.69d` (soon to become 2.70):

```
$ ./configure
./configure: line 8720: syntax error near unexpected token `fi'
./configure: line 8720: `fi'
```

Before the change generated `./configure ` snippet looked like:

```
    if ! $CC -E -xc - <<SRC >/dev/null
then :

	#if defined __APPLE_CC__ && defined __clang_major__ && __clang_major__ < 3
	#error premature clang
	#endif
SRC
	as_fn_error $? "clang version 3.0 or later is required" "$LINENO" 5
fi
```

Note the newline that breaks here-document syntax.

After the change the snippet does not use here-document.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2020-11-17 09:41:59 +09:00
Nobuyoshi Nakada b958e2add8 Removed canonicalization for mathn 2020-11-10 11:14:15 +09:00
Nobuyoshi Nakada ed01cc8fdc
No longer need libtool
As debug_counter.c has had a global symbol since cdc614cd0a,
ranlib should no longer complain that it has no symbols.
2020-10-06 23:46:24 +09:00
Nobuyoshi Nakada 67ae1d441d
Do not use clang on cygwin
Its `__has_declspec_attribute()` is not reliable.  For instance,
while `__has_declspec_attribute(noalias)` is true but 'noalias'
attribute is warned as unknown.
2020-09-28 13:42:04 +09:00
卜部昌平 e9fb2bc873 RBIMPL_ALIGNOF: do not use __alignof__
It is reported that on a system of i386 System V ABI, GCC returns 8 for
__alignof__(double).  OTOH the ABI defines alignments of double to be 4,
and ISO/IEC 9899:2011 reads that _Alignof(double) shall return 4 on such
machine.  What we want in ruby is 4 instead of 8 there.  We cannot use
__alignof__.

Additionally, both old GCC / old clang return 8 for _Alignof(double) on
such platforms.  They are their bugs, and already fixed in recent
versions.  But we have to support older compilers for a while.  Shall
check sanity of _Alignof.
2020-09-25 11:38:33 +09:00
卜部昌平 fe875be01a rb_cv_have_alignas: not used any longer
Availability of `alignas` is checked in include/ruby/internal/stdalign.h
now.  That does not need this configure check.  Also as commented in the
header, we see `_Alignas` being inadequate for our purpose.
2020-09-25 11:38:33 +09:00
Masaki Matsushita 0ac185be40 Fix compile-time check for copy_file_range(2)
* close fds properly
* define USE_COPY_FILE_RANGE if HAVE_COPY_FILE_RANGE is defined
* avoid errors on cross-compiling environments
2020-09-12 16:27:14 +09:00
Masaki Matsushita 012785ef35 Check copy_file_range(2) is actually supported.
see also: https://gitlab.com/gitlab-org/gitlab/-/issues/218999#note_363225872
2020-09-12 16:07:35 +09:00
卜部昌平 50b18e8129 configure: detect that there is no g++
AC_PROG_CXX checks for several C++ compilers INCLUDING g++.  When none
of them were found it sets the CXX variable to be g++.  This doesn't
make any sense.  Absense of g++ has already been made sure.

Because we don't want insanity (that's the whole reason we test the
environment using autoconf), we need to swipe such insane variable out.
2020-09-03 15:14:09 +09:00
Jeremy Evans be9dbe1c3e Fix pthread_setname_np arguments on NetBSD
The previous attempt to fix this in
b87df1bf24 reversed the argument
order instead of just fixing the quote escaping.

From Takahiro Kambe.

Fixes [Bug #15178]
2020-09-01 07:16:31 -07:00
卜部昌平 b01d852c2a congigure.ac: favour gcc on Linux
Requested by Naruse.
2020-09-01 11:05:10 +09:00
卜部昌平 21b3bc10d3 DEPRECATED_TYPE: is deprecated
Nobody uses this macro any longer.
2020-08-27 15:02:52 +09:00
卜部昌平 2ddc67ffb6 configure.ac: suppress more Sun C warnings.
They are rather annoying than being useful to us.
2020-08-22 14:12:12 +09:00
卜部昌平 d916a4c897 configure.ac: more checks on STRIP
STRIP now depends on compilers, not on OS.  Previous check against
$target_os does no longer work.
2020-08-22 09:49:08 +09:00
卜部昌平 914b2208ab configure.ac: rule out old Sun C++
CI failures observed for old Sun C++.  We don't want to hustle, as newer
versions are okay.  Just check the sanity and rule out insane compilers.
2020-08-22 00:45:39 +09:00
卜部昌平 954afd1bc5 protect CFLAGS from being smashed by AC_PROG_CC
AC_PROG_CC_C99 calls AC_PROC_CC, which calls _AC_PROG_CC_G, which sets
default CFLAGS, whose contents are not customisable.  We don't welcome
this behaviour.

The exact same thing happens for CXXFLAGS in AC_PROG_CXX.
2020-08-22 00:45:39 +09:00
卜部昌平 3eb76e747e configure.ac: try GCC-provided ld
In case of cross-compilation, GCC might provide its own linker.  Its
behaviour seems slightly different from that of gcc(1).  This is not a
big deal for normal situations, but the difference can cause libtool to
go mad.

We ship bundled libffi for windows users, and libffi uses libtool.  If
we use cross-compiler version of gcc instead of its ld conterpart, we
fail to compile fiddle.  That should not be what we want.
2020-08-21 16:01:46 +09:00
卜部昌平 73b6bc5790 AC_PROG_CXXCPP: remove
Caused CI failures on environments without sane C++ compilers.
2020-08-21 11:47:18 +09:00
卜部昌平 7341b1a53d configure.ac: move program_transform_name
Historically `$program_transform_name` has been put in front of
`AC_CANONICAL_TARGET`.  Previous commit changes it, which affects the
name of generated ruby binary when cross-compiling.  I _guess_ the
historical behaviour is a bug (name of ruby binary shall honour --target
configure option I think), but anyways here I preserve that questionable
way.
2020-08-21 11:04:54 +09:00
卜部昌平 2c96e04868 configure.ac: use compiler-provided toolchains
These days as link-time optimisations spread accross compilers, they
tend to ship their own version of ld, ar, etc.  Why not detect such
things if any.  Users can select compilers by ./configure --with-gcc=
whatever, or select individual tool by e.g. ./configure NM=whatever.

The added AC_ARG_VAR macros enrich ./configure --help output.
2020-08-21 11:04:54 +09:00
Nobuyoshi Nakada 50aac2ffd5
Share the size for sigaltstack between configure.ac and signal.c 2020-07-22 21:28:23 +09:00
Jake Zimmerman 8b0dc77a62 configure.ac: Bump the size of sigaltstack
The RubyVM uses C macro defines to feature detect whether
`backtrace(2)` support is available, and if so it includes C level backtraces
when the RubyVM itself crashes.

But on my machine, C level backtraces from `vm_dump.c` didn't work when
using a version of Ruby buillt on the machine, but worked fine when using a
version of Ruby built on another machine and copied to my machine.

The default autoconf test for backtraces uses a sigaltstack size that is
too small, so the SIGSEGV signal handler itself causes a SIGSEGV).
I noticed that signal.c uses a larger sigaltstack size:

https://github.com/ruby/ruby/blob/v2_6_5/signal.c#L568

The specific variables it looks at:

- `HAVE_BACKTRACE`

  this is a macro defined by autoconf because there is a line in the
  configure script like `AC_CHECK_FUNCS(backtrace)` (see the autoconf
  docs for more).

- `BROKEN_BACKTRACE`

  this comes from a custom program that Ruby's configure script runs to
  attempt to figure out whether actually using backtrace(2) in a real
  program works. You can see the autoconf program here.

  <https://github.com/ruby/ruby/blob/v2_6_5/configure.ac#L2817-L2863>

It uses sigaltstack and SA_ONSTACK to create a seperate stack for
handling signals.

The problem was: SIGSTKSZ (which comes from a system header!) was not
suggesting a large enough stack size. When checking on an Ubuntu 16.04
box, we found that SIGSTKSZ was 8192 and MINSIGSTKSZ was 2048.
2020-07-22 20:46:36 +09:00
Nobuyoshi Nakada a0a5eec0e7
Bail out when unsupported coroutine target 2020-07-09 13:53:20 +09:00
Watson 23655e6de5 Fix build error on Apple silicon macOS
This patch will fix following build error on macOS 11.0 + Xcode 12 beta.

```
$ ./configure
$ make V=1
	BASERUBY = /Users/watson/.rbenv/shims/ruby --disable=gems
	CC = clang -fdeclspec
	LD = ld
	LDSHARED = clang -fdeclspec -dynamiclib
	CFLAGS = -O3 -ggdb3 -Wall -Wextra -Werror=deprecated-declarations -Werror=division-by-zero -Werror=implicit-function-declaration -Werror=implicit-int -Werror=misleading-indentation -Werror=pointer-arith -Werror=shorten-64-to-32 -Werror=write-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Werror=extra-tokens -std=gnu99  -pipe
	XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -DRUBY_DEVEL=1 -fvisibility=hidden -DRUBY_EXPORT -fPIE -DCANONICALIZATION_FOR_MATHN -I. -I.ext/include/arm64-darwin20 -I./include -I. -I./enc/unicode/12.1.0
	CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT
	DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -fstack-protector-strong -Wl,-pie -framework Security -framework Foundation
	SOLIBS = -lpthread -ldl -lobjc
	LANG = ja_JP.UTF-8
	LC_ALL =
	LC_CTYPE =
	MFLAGS =
Apple clang version 12.0.0 (clang-1200.0.22.19)
Target: arm64-apple-darwin20.0.0
Thread model: posix
InstalledDir: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang -fdeclspec -O3 -ggdb3 -Wall -Wextra -Werror=deprecated-declarations -Werror=division-by-zero -Werror=implicit-function-declaration -Werror=implicit-int -Werror=misleading-indentation -Werror=pointer-arith -Werror=shorten-64-to-32 -Werror=write-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Werror=extra-tokens -std=gnu99  -pipe  -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -DRUBY_DEVEL=1 -fvisibility=hidden -DRUBY_EXPORT -fPIE -DCANONICALIZATION_FOR_MATHN -I. -I.ext/include/arm64-darwin20 -I./include -I. -I./enc/unicode/12.1.0 -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -o cont.o -c cont.c
In file included from cont.c:19:
./coroutine/ucontext/Context.h:32:5: error: 'getcontext' is deprecated: first deprecated in macOS 10.6 [-Werror,-Wdeprecated-declarations]
    getcontext(&context->state);
    ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ucontext.h:37:6: note: 'getcontext' has been
      explicitly marked deprecated here
int  getcontext(ucontext_t *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
     ^
In file included from cont.c:19:
./coroutine/ucontext/Context.h:51:5: error: 'makecontext' is deprecated: first deprecated in macOS 10.6 [-Werror,-Wdeprecated-declarations]
    makecontext(&context->state, (void(*)(void))coroutine_trampoline, 2, (void*)start, (void*)context);
    ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ucontext.h:38:6: note: 'makecontext' has been
      explicitly marked deprecated here
void makecontext(ucontext_t *, void (*)(), int, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHI...
     ^
In file included from cont.c:19:
./coroutine/ucontext/Context.h:59:5: error: 'swapcontext' is deprecated: first deprecated in macOS 10.6 [-Werror,-Wdeprecated-declarations]
    swapcontext(&current->state, &target->state);
    ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ucontext.h:40:6: note: 'swapcontext' has been
      explicitly marked deprecated here
int  swapcontext(ucontext_t * __restrict, const ucontext_t * __restrict) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_...
     ^
3 errors generated.
make: *** [cont.o] Error 1
```
2020-07-08 22:56:49 +09:00
Nobuyoshi Nakada 047471c529
No GITPULLOPTIONS by default
To honor the environment variable, keep GITPULLOPTIONS unset by
default, and appended the option to VCSUP.
2020-06-04 13:16:24 +09:00
Jeremy Evans 9a3371be8f Check that BASERUBY is at least Ruby 2.2 in configure
BASERUBY needs to be at least Ruby 2.2 since
46acd0075d.

I think it's better to explicitly fail early as soon as BASERUBY
is used in this case, versus trying to debug later failures.

This modifies things to check both implicitly use of ruby in the
PATH as BASERUBY, and explicitly specified older versions of ruby
when using --with-baseruby.

Fixes [Bug #16668]
2020-05-28 07:57:29 -07:00
Alan D. Salewski c15cddd1d5 Allow Dir.home to work for non-login procs when $HOME not set
Allow the 'Dir.home' method to reliably locate the user's home directory when
all three of the following are true at the same time:

    1. Ruby is running on a Unix-like OS
    2. The $HOME environment variable is not set
    3. The process is not a descendant of login(1) (or a work-alike)

The prior behavior was that the lookup could only work for login-descended
processes.

This is accomplished by looking up the user's record in the password database
by uid (getpwuid_r(3)) as a fallback to the lookup by name (getpwname_r(3))
which is still attempted first (based on the name, if any, returned by
getlogin_r(3)).

If getlogin_r(3), getpwnam_r(3), and/or getpwuid_r(3) is not available at
compile time, will fallback on using their respective non-*_r() variants:
getlogin(3), getpwnam(3), and/or getpwuid(3).

The rationale for attempting to do the lookup by name prior to doing it by uid
is to accommodate the possibility of multiple login names (each with its own
record in the password database, so each with a potentially different home
directory) being mapped to the same uid (as is explicitly allowed for by
POSIX; see getlogin(3posix)).

Preserves the existing behavior for login-descended processes, and adds the
new capability of having Dir.home being able to find the user's home directory
for non-login-descended processes.

Fixes [Bug #16787]

Related discussion:
    https://bugs.ruby-lang.org/issues/16787
    https://github.com/ruby/ruby/pull/3034
2020-05-23 23:16:28 +09:00
Nobuyoshi Nakada 39cb19303c
Search pkg-config with ac_tool_prefix [Bug #16909]
Should prefer a prefixed version over the bare pkg-config for
cross compiling.
2020-05-23 22:04:11 +09:00
Nobuyoshi Nakada b722182e47
Revert "Search pkg-config by AC_CHECK_TOOL [Bug #16909]"
This reverts commit 6006ab8cf9.
AC_CHECK_TOOL does not have REJECT argument.
2020-05-23 21:20:34 +09:00
Nobuyoshi Nakada 6006ab8cf9
Search pkg-config by AC_CHECK_TOOL [Bug #16909]
It should use AC_CHECK_TOOL to automatically search for a prefixed
version and not just the bare pkg-config.
2020-05-23 19:52:14 +09:00
Nobuyoshi Nakada c89c3801b9
BASERUBY have to be 1.9 or later at least [Bug #16845]
Many tools under tool directory haven't worked with ruby 1.8.
2020-05-11 03:19:36 +09:00
Nobuyoshi Nakada a1e1fdca09
Fallback MAKE to make 2020-05-11 00:40:14 +09:00
Nobuyoshi Nakada 3fa4fd4780
Pass MAKE value to configure for non-default name case
GNU make does not export it by default.
2020-05-11 00:18:06 +09:00
Nobuyoshi Nakada e49ecaed57
Optimize sin/cos
GCC/Clang can optimize to calculate `sin(x)` and `cos(x)` at once,
when the both are closely called on the same argument.

Similar optimization is possible for `__sinpi(x)` and `__cospi(x)`
if available, which calculate arguments in radian, i.e.
`sin(x*M_PI)` and `cos(x*M_PI)` respectively.
2020-05-03 15:29:51 +09:00
Yusuke Endoh 92afac8f33 configure.ac: Automatically add -D__ANDROID_API=ver on Android 2020-04-22 02:31:37 +09:00
Andreas Schwab abe2e7de4d Don't require sub-word atomics
On some architectures (like RISC-V) sub-word atomics are only available
when linking against -latomic, but the configure script doesn't do that,
causing the atomic checks to fail and the resulting ruby binary is
non-functional.  Ruby does not use sub-word atomic operations, rb_atomic_t
is defined to unsigned int, so use unsigned int when checking for atomic
operations.
2020-04-11 11:19:50 +09:00