Commit graph

94 commits

Author SHA1 Message Date
Mislav Marohnić
cf383ac114
Fixes "integer expression expected" error
This happens while compiling OpenSSL or any other non-Ruby package:

    ruby-build: line 723: [: : integer expression expected

This was because $ruby_semver was checked as a numeric value but was never set.
2025-09-25 13:50:49 +02:00
Mislav Marohnić
28563f38a3
Fix using system openssl v1.x with pkg-config
System openssl version reported by `pkg-config --modversion openssl` might end
with a letter, e.g. "1.0.2k", due to OpenSSL versioning policy prior to OpenSSL v3:
https://www.openssl-library.org/policies/general/versioning-policy/#history

The letter would trip up the normalize_semver function due to it only handling numbers.

This change switches to semver parsing via awk instead of doing it clumsily in
bash.  This also changes the multiplication factor of major version numbers,
from 100000 to 10000, and adjusts static version comparisons accodingly.
2025-09-08 19:07:28 +02:00
Mislav Marohnić
95b887330e
Fix linking to Homebrew OpenSSL 2025-08-14 12:33:22 +02:00
Nicolas Bachschmidt
fd0f332f06
Consult pkg-config when detecting system OpenSSL (#2547)
Skip downloading and building OpenSSL if a compatible version was found with pkg-config, but only if that openssl version isn't under Homebrew's "cellar".

---------

Co-authored-by: Mislav Marohnić <git@mislav.net>
2025-08-12 13:56:42 +02:00
Benoit Daloze
5d0b95764b Improve test for building OpenSSL under macOS
Co-authored-by: Mislav Marohnić <git@mislav.net>
2025-01-15 15:22:21 +01:00
Benoit Daloze
4b363d67d5 Simplify logic for rpath, the comma syntax is supported by all compilers
* From https://github.com/rbenv/ruby-build/pull/2496/files#r1915751424
2025-01-15 15:22:21 +01:00
Mislav Marohnić
afb5dcc402
Fix installing OpenSSL on non-Linux or with clang
The recent rpath argument addition broke compilation of OpenSSL with clang since
it seems expect this syntax (comma instead of "="):

    -Wl,-rpath,<path>

Also, it doesn't seem that the rpath argument is necessary for any platform other
than "Linux"; that is, we should skip passing it on BSD and macOS.
2025-01-14 23:32:57 +01:00
Mislav Marohnić
068c4047cf
Fix library lookup path in the vendored OpenSSL (#2493)
* Fix library lookup path in the vendored OpenSSL

When a vendored OpenSSL is needed for compiling Ruby, that OpenSSL installation
ends up with its `bin/openssl` executable broken due to not finding "libssl.so"
and "libcrypto.so" in the global load path for libraries. This doesn't seem to
negatively affect the Ruby "openssl" extension, but is a broken OpenSSL install
nevertheless.

This change causes the `bin/openssl` executable and related shared libraries to
be built with an "RPATH" pointing to the "lib" directory of the vendored OpenSSL.

* fix test
2025-01-11 15:15:26 +01:00
Mislav Marohnić
14d3185545
Fix linking to vendored OpenSSL on 64-bit systems
On 64-bit systems, the build system for OpenSSL tends to produce a "lib64"
directory instead of a "lib" directory due to its "multilib" feature being
enabled by default. However, the Ruby "openssl" extension assumes that the
directory is always named "lib", or explicitly passed via `--with-openssl-lib`.

This disables multilib support in OpenSSL by passing `--libdir=lib` to OpenSSL
configure step.
2024-10-15 14:24:13 +02:00
Benoit Daloze
572dd651de Use --enable-shared for dev builds too, not only for releases
* Only from Ruby 2.4+ since older releases don't use --enable-shared by default.
* As with releases it can be disabled by setting RUBY_CONFIGURE_OPTS=--disable-shared.
2024-10-09 01:50:09 +02:00
Benoit Daloze
a22ff72e32
Support ruby-build ruby-X.Y.Z DIR (#2448)
* By searching a X.Y.Z definition if no ruby-X.Y.Z definition is not found.
* Add test and documentation.

Co-authored-by: Mislav Marohnić <git@mislav.net>
2024-09-23 19:15:29 +02:00
Benoit Daloze
2d00d407e7
Add -d, --dir option to install to <prefix>/<definition> instead of <prefix> (#2447)
Similar to ruby-install's -r, --rubies-dir flag.

---------

Co-authored-by: Mislav Marohnić <git@mislav.net>
2024-09-23 18:00:15 +02:00
Mislav Marohnić
fb1b4da13d
Simplify JRuby version check
In case shelling out to jruby fails, the error output wouldn't get printed to
stderr but ruby-build would abort.
2024-06-10 11:54:48 +02:00
Mislav Marohnić
8465e028e8
Skip passing --with-readline-dir for Ruby 3.3+ 2024-01-07 14:24:40 +01:00
Mislav Marohnić
89617471f8
Fix linking to older OpenSSL for Ruby < 2.7.7
Explicitly set PKG_CONFIG_PATH when `--with-openssl-dir` is used for older Rubies.
Otherwise, Ruby will attempt to link to the latest OpenSSL found by pkg-config,
which could be incompatible.
2023-12-07 15:52:10 +01:00
Mislav Marohnić
c5346187ac
Simplify build & install steps for dev rubies
This merges "standard_build" and "standard_install" build steps into one again
and modifies "standard_install_with_bundled_gems" to just invoke "standard"
with the addition of `update-gems` & `extract-gems` targets.
2023-11-30 16:32:57 +01:00
Mislav Marohnić
efe73b4841
Fix compiling Ruby < 2.5 by omitting --with-ext
Using `--with-ext=+` only has the indended effect (compiling all extensions that would normally get compiled) on Ruby 2.5+. On older versions, it causes none of the default extensions to get compiled, resulting in a defunct installation.
2023-11-24 22:08:28 +01:00
Mislav Marohnić
6250069ccb
Instruct Ruby to fail the build if openssl or psych are missing
Normally, Ruby `make` step will print a warning about any missing
extensions, but will not abort the build and instead proceed as normal.

Since Ruby installations without openssl or psych are essentially
broken, ruby-build used to have a `verify_openssl` build step to test if
the newly built Ruby can load these extensions, and print helpful
information and abort the build on errors:

    Loading the Ruby openssl extension failed
    ERROR: Ruby install aborted due to missing extensions

The `verify_opensl` implementation was necessary to provide a good
experience for ruby-build users, but was hacky and I would prefer to
eliminate it.

It appears that passing `--with-ext=openssl,psych` to the Ruby configure
step marks those extensions as mandatory and fails the `make` process if
they failed to build. This is exactly the behavior we want, so this
enables the configure option for all Ruby builds.
2023-11-21 17:12:53 +01:00
Mislav Marohnić
56242478b1
Simplify build_package_rbx
This removes the `isolated_gem_dependency` hack as well as the `rake` &
`bundle` shell wrapper functions. The main reason is to avoid having to
use the `command` shell builtin to be able to invoke the real `rake` and
`bundle`. In my testing on bash 3.2, `command` does not respect the
usual bash error handling rules, and thus a failed `command` invocation
can trigger the ERR trap mechanism even when we don't want it to.
2023-11-07 10:51:43 +01:00
Mislav Marohnić
f6923c65f0
Fix checking system OpenSSL version
The value of OPENSSL_VERSION_TEXT seems to be printed in double quotes.
2023-11-05 13:56:45 +01:00
Mislav Marohnić
31e53468b6
Automatically link to Homebrew OpenSSL
If a system OpenSSL version was not found or is at version that is incompatible with a Ruby being installed, ruby-build would typically download and compile a new OpenSSL version scoped to that Ruby installation.

Now the `needs_openssl` condition will also check for Homebrew-installed OpenSSL and automatically link to the first one found that satisfies the version requirement. This primarily helps speed up Ruby installation on macOS where the system OpenSSL is never compatible and where Homebrew is a de-facto standard package manager.
2023-11-02 13:53:50 +01:00
Benoit Daloze
39f77ffd17 Skip ri/rdoc when installing jruby-launcher 2023-10-23 12:28:10 +02:00
Mislav Marohnić
08b1cfaf71
Add needs_openssl test 2023-10-17 15:33:08 +02:00
Mislav Marohnić
a559b30fd8
Improve cached_tarball test helper
- Now only generates a `configure` script if explicitly specified
- Add ability to add arbitrary files to the tarball
- Cache most common tarballs in fixtures directory to speed up tests
2023-10-17 12:40:17 +02:00
Mislav Marohnić
47eda17460
Remove implicit LDFLAGS, CPPFLAGS, and "ldflags_dirs" build step
The default settings for LDFLAGS and CPPFLAGS were there since the initial commit to ruby-build:

    LDFLAGS="-L${PREFIX_PATH}/lib"
    CPPFLAGS="-I${PREFIX_PATH}/include"

However, it's not clear to me what these settings help with. A typical Ruby installation will initialize files in these directories, but it will do so regardless of the environment variables.

So, let's remove them and see what breaks.
2023-10-13 19:21:04 +02:00
Mislav Marohnić
1c8689b950
Add tests for extra configure flags on the command-line 2023-10-11 18:02:07 +02:00
Mislav Marohnić
6b6fa457a0
Enable test assertions to spot erraneous word-splitting in bash 2023-10-11 18:02:07 +02:00
Thomas Hurst
4cec390699
Set default MAKE=make on FreeBSD (#2263)
This was set to gmake in https://github.com/rbenv/ruby-build/pull/1381
as a workaround for https://bugs.ruby-lang.org/issues/16331

YJIT builds in Ruby 3.3 previews require the use of BSD make on these
platforms, and no supported version of MRI requires the use of gmake, so
revert this.

JRuby continues to require gmake for jruby-launcher.

Fixes #2262

Co-authored-by: Mislav Marohnić <git@mislav.net>
2023-10-11 12:19:40 +02:00
João Duarte
c6e924edc8
workaround jruby#7799 by updating rubygems for JRuby 9.2.x (#2246)
Co-authored-by: Mislav Marohnić <git@mislav.net>
2023-09-12 16:08:47 +02:00
Mislav Marohnić
242e8beb49
Avoid test failure when stubbing FreeBSD environment
https://github.com/rbenv/ruby-build/actions/runs/5719870214/job/15517987944#step:4:18
2023-08-02 11:20:08 +02:00
Mislav Marohnić
4079aa75cd
add stub_repeated test helper 2023-03-06 19:15:49 +01:00
Roman Usherenko
40af31b46b
automatically detect and use Homebrew's libyaml
Co-authored-by: Mislav Marohnić <git@mislav.net>
2023-03-06 19:14:40 +01:00
Jean Boussier
1f9b792168 macOS: Use GMP from homebrew
MRI's BigInt use GMP under the hood if available, and if not
fallbacks to an homemade implementation with much worse performance.

Without GMP:
```
>> Benchmark.realtime { Integer('1' * (10 ** 7)) }
=> 13.80743500002427
```

With GMP
```
>> Benchmark.realtime { Integer('1' * (10 ** 7)) }
=> 0.4098639999865554
```

macOS not being a common production platform, it's not a huge deal
but it would still preferable to compile with `gmp.h` if present.

I'd also suggest to print a warning if compiling on macOS and gmp
isn't installed, but I don't know if it's desirable.

NB: `--with-gmp-dir` was only added recently, so this will only
apply to MRI >= 3.2, as well as rubies on which this flag was backported.
2022-09-22 08:56:34 +02:00
Benoit Daloze
e607953dbf Fix version check for Java 17
* Fixes https://github.com/rbenv/ruby-build/issues/1798
* OpenJDK 17 reports:
  $ java -version
  openjdk version "17" 2021-09-14
  There is no dot in the version, so we need to only use the first match from grep -o.
* Clarify it is a minimum required java version, not an exact version.
2021-09-28 12:42:07 +02:00
Benoit Daloze
ac72249e04 Ensure it is safe to remove the prefix path for TruffleRuby or error
* Only do clean_prefix_path for TruffleRuby and rename for clarity,
  since the logic is now TruffleRuby-specific.
2021-07-26 17:44:28 +02:00
Mislav Marohnić
d6af53ef1c Fix test for gmake on FreeBSD 2019-11-20 10:56:16 +01:00
Mislav Marohnić
ed46d03947 Include header files with mruby
Fix #1311
2019-11-05 11:03:49 +01:00
Mislav Marohnić
8945b5721f Add tests for different styles of patches 2019-11-05 09:48:22 +01:00
Mislav Marohnić
c30d4cba91 Fix verifying Java 9+ versions
Ref. #1135
2019-11-02 13:09:38 +01:00
Mislav Marohnić
9219a43caf
Merge pull request #1198 from yyuu/http-client-based-on-envvar
Allow overriding HTTP client type based on environment variable of `RUBY_BUILD_HTTP_CLIENT`
2018-08-22 11:27:06 +00:00
Benoit Daloze
0ec626bc4d Remove early check for LLVM when installing TruffleRuby
* TruffleRuby already checks for LLVM itself when it needs it and
  looks up more paths to find the LLVM executables clang and opt.
* See https://github.com/oracle/truffleruby/issues/1386.
2018-07-14 22:39:37 +02:00
Benoit Daloze
a8a3ebf809 Add tests for TruffleRuby 2018-06-15 20:17:13 +02:00
Yamashita, Yuu
34652a4fae Allow overriding HTTP client type based on environment variable RUBY_BUILD_HTTP_CLIENT (pyenv/pyenv#1126) 2018-04-26 02:08:59 +00:00
SHIBATA Hiroshi
331a408adc
Merge pull request #1136 from juanibiapina/relax-java-version-regexp
Relax java version regexp
2017-11-27 15:26:35 +09:00
SHIBATA Hiroshi
f41e8474a8
ubygems.rb is unavailable on Ruby 2.5 2017-10-12 11:57:46 +09:00
Juan Ibiapina
4889ec7ca6 Relax java version regexp
This allows the java version to be specified as "9", instead of "1.9".

Closes #1135
2017-10-09 12:54:13 +02:00
Yuichiro NAITO
ea90779a98 Add test of FreeBSD-11. 2017-01-27 10:49:56 +09:00
Yuichiro NAITO
0a347a4537 stub uname for Non Linux environment 2016-12-21 10:52:25 +09:00
Yuichiro NAITO
646bb47b81 add stub uname default value 2016-11-24 16:12:00 +09:00
Yamashita, Yuu
b3ba8c8666 Use curl stub during tests by default 2016-06-10 05:11:26 +00:00