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

684 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada 2951e3d83b
Allow nmake to ignore errors
cmd.exe can redirect file descriptor other than STDOUT, while
command.com couldn't.
2023-07-10 19:21:47 +09:00
Nobuyoshi Nakada c8d0470bb0
Use `File::NULL` instead of hard coded null device names 2023-07-10 19:21:47 +09:00
Jun Aruga 57459b83a9
mkmf: Add the extra option `--with-verbose` to enable verbose mode. (#7863)
This commit is to add an extra option to enable verbose mode (V=1) in the
generated `Makefile` at runtime of the Ruby to print compiler command lines by
the commands below when building native extensions. It's possible to enable the
verbose mode by setting the environment variable `MAKEFLAGS="V=1"`[1]
implemented in GNU make. However, I wanted to make a consistent user-interface
not depending on the specific make's implementation.

```
$ ruby /path/to/extconf.rb -- --with-verbose
```

You can also add the extra option via rake-compiler gem.

```
$ rake compiler -- --with-verbose
```

If the extra option is not given, the value of the
`RbConfig::CONFIG["MKMF_VERBOSE"]` enabled by the configure option below is
used.

```
$ ./configure --enable-mkmf-verbose
```

For the unit tests, updated the following files.

* The `test/mkmf/test_configuration.rb` was created to test the cases with the
  `configuration` method and this implementation.
* Updated the `TestMkmf#assert_separately` to set the extra
  arguments in `test/mkmf/base.rb`. Updated tests using the `assert_separately`.
* Added tests for `MakeMakefile#with_config` in the `test/mkmf/test_config.rb`.

[1] https://www.gnu.org/software/make/manual/html_node/Variables_002fRecursion.html

Fixes [Bug #19695]

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2023-05-29 10:09:32 +02:00
Nobuyoshi Nakada 29dc9378d9 mkmf.rb: Refine message from `pkg_config` 2023-01-09 21:44:15 +09:00
Nobuyoshi Nakada 0d7bbfc941 mkmf.rb: Prefer `caller_locations` over parsing `caller` 2023-01-09 21:44:15 +09:00
Nobuyoshi Nakada b94656147b mkmf.rb: Refactor splitting configure_args and remove duplicate code 2023-01-06 20:00:53 +09:00
Nobuyoshi Nakada 613fca0148 [Bug #19189] Fallback to the default "pkg-config" 2022-12-15 11:00:42 +09:00
Nobuyoshi Nakada facb5cd4d5
Clean compiler intermediate files more 2022-12-05 17:09:49 +09:00
Nobuyoshi Nakada 612aa5c24a
Use class methods of `File` over `Kernel.open` and `IO.read` 2022-11-21 22:16:49 +09:00
Nobuyoshi Nakada 6700fa7f62
Set timestamp path for the target path to TARGET_SO_DIR_TIMESTAMP 2022-10-24 17:48:00 +09:00
Nobuyoshi Nakada 7f1ca66642
Fallback PKG_CONFIG to the configured pkg-config always 2022-10-02 15:19:14 +09:00
Nobuyoshi Nakada 6898984f1c
[Bug #19005] dynamic_lookup linker option in external libraries
The warning against `-undefined dynamic_lookup` is just a warning yet,
and many gems seem to pay no attention to warnings.  Until it fails
actually, keep it as a migration path, except for standard extension
libraries and bundled extension gems.
2022-09-17 12:09:34 +09:00
Alan Wu e5a3f23256 Use $(bindir) for path to executable in mkmf
For the macOS -bundle_loader linker option, we need a path to the
Ruby exectuable. $(RUBY) is not necessarily a path since it could
be a command line invocation. That happens during build with
runruby.rb and can happen post installation if the user passes
the --ruby option to a extconf.rb. Use $(bindir) to locate
the executable instead.

Before installation, $(bindir) doesn't exist, so we need to be
able to override $(BUILTRUBY) in such situations so test-spec
and bundled extensions could build. Use a new mkmf global,
$builtruby, to do this; set it in fake.rb and in extmk.rb.

Our build system is quite complex...
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
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
Kaíque Kandy Koga bdb7345ce9 Use compiled instead of complied
Capitalize creates
2022-04-26 12:38:51 -07:00
Kazuhiro NISHIYAMA e142bea799 Remove unnecessary sort
Because `Dir.[]` returns the sorted results since Ruby 3.0.
2022-04-23 11:59:20 +09:00
Alan Wu 2304cfa4c0 Document MakeMakefile#append_cflags
This method is at least 7 years old and is widely used in the wild.
Since we need to support it, let's document it to make it discoverable.
Add docs and move it out of the `# :stopdoc:` zone.
2022-04-05 12:57:55 -04:00
Nobuyoshi Nakada 6946263a29
[DOC] make internally used classes/methods nodoc
Empty class documents are generated even with `:stopdoc:`.
2022-03-20 14:26:20 +09:00
Nobuyoshi Nakada 329c89bb42
Make implicit function declaration error [Feature #18615]
Enable `-Werror=implicit-function-declaration` by default for
building C extensions for early failures.
2022-03-17 14:37:34 +09:00
Nobuyoshi Nakada 7672f6a423
mkmf: unify duplicate code in pkg_config 2022-01-29 15:29:46 +09:00
Mike Dalessio b90e56e624 mkmf: pkg_config accepts multiple options 2022-01-29 15:22:52 +09:00
Nobuyoshi Nakada 30268d1de6
Prefer flat_map 2021-12-10 18:39:48 +09:00
Nobuyoshi Nakada dff8d12226 mkmf: take `PKG_CONFIG_PATH` from `dir_config` library path
So that version dependent pkg-config files can override files in
the default locations.
2021-11-26 22:32:26 +09:00
Nobuyoshi Nakada 21a29844a3 mkmf: deal with environment variables in MakeMakefile#xpopen 2021-11-26 22:32:26 +09:00
Nobuyoshi Nakada 1c3d6d6cc9 mkmf: MakeMakefile#xpopen may be passed an option hash 2021-11-26 22:32:26 +09:00
Nobuyoshi Nakada 19beb028e7
Make explicit opening files 2021-10-15 19:59:14 +09:00
Nobuyoshi Nakada ea64e742f5
Revert "mkmf.rb: try linking at try_var" [Bug #18235]
This reverts commit 524513be39,
which can return false positive by existing but unusable symbol,
including functions.
2021-10-03 18:23:39 +09:00
Nobuyoshi Nakada cb5a41c0a0
Get rid of incompatible-pointer-types-discards-qualifiers warning 2021-09-02 08:47:47 +09:00
Nobuyoshi Nakada 524513be39
mkmf.rb: try linking at try_var
To check for variables accessible but not declared.
2021-07-08 18:18:35 +09:00
Nobuyoshi Nakada 287fb680e2
Library arguments to VC are bare file names 2021-07-03 12:52:46 +09:00
Nobuyoshi Nakada 1ac228378c
Use $ignore_error defined in mkmf.rb 2021-07-03 12:52:46 +09:00
Nobuyoshi Nakada 627aafac86
Remove also debug symbol directory at clean on macOS 2021-06-24 17:04:42 +09:00
Nobuyoshi Nakada 1356b90c91
Prefer configured command as RM_RF 2021-06-24 17:04:41 +09:00
Nobuyoshi Nakada 799ea1d154
mkmf.rb: convert also arch_hdrdir [Bug #16651] 2021-04-11 21:59:45 +09:00
Nobuyoshi Nakada 5cdf99f64e
mkmf: fixed install directories of header files in extension libraries [Bug #17761]
When installing an extension library which provides a header, that
header should be installed under site_ruby (or vendor_ruby when
"--vendor" option was given to extconf.rb).  However, currently
this file is about to be installed in the core include directory.
2021-03-30 23:28:49 +09:00
Nobuyoshi Nakada cc8e966e3c
MSys is a variant of Cygwin 2021-02-20 23:33:22 +09:00
Gannon McGibbon 9e0075a3d9 Replace "iff" with "if and only if"
iff means if and only if, but readers without that knowledge might
assume this to be a spelling mistake. To me, this seems like
exclusionary language that is unnecessary. Simply using "if and only if"
instead should suffice.
2021-01-19 12:06:45 -08:00
Nobuyoshi Nakada 7f3c5e65c6
mkmf.rb: remove exts.mk at distclean 2021-01-14 00:17:23 +09:00
Nobuyoshi Nakada 4b6fd8329b
mkmf.rb: always try_compile as try_header
Get rid of "present but cannot be compiled" headers, on some
multi-architecture platforms.
2021-01-02 12:11:02 +09:00
Nobuyoshi Nakada d57c5a7b61 transcode-tblgen.rb: make silent a little when just -v 2020-12-29 17:45:19 +09:00
Nobuyoshi Nakada 3198e7abd7
Separate `send` into `public_send` and `__send__` 2020-10-27 16:12:45 +09:00
Nobuyoshi Nakada c2a6295ec0
Make the mkmf methods private in the global [Bug #16896] 2020-07-13 18:44:22 +09:00
Nobuyoshi Nakada 21d0b40de2 Added tooldir variable 2020-04-05 09:26:57 +09:00
Nobuyoshi Nakada 2b7409a2f2
Specify explicit separator not to be affected by $; 2020-03-08 17:38:37 +09:00
Nobuyoshi Nakada 6180f1fede
Added link_command for C++ 2019-09-19 19:06:18 +09:00
Nobuyoshi Nakada e2aac6a611
Separate @have_devel for C++ 2019-09-19 12:25:48 +09:00
Nobuyoshi Nakada 842f600a93
Look up the language module
Look up language module with `MakeMakefile.[]`, insted of a
accessing constant under that module directly, to get rid of
expose the constant to the toplevel inadvertently.
2019-09-19 00:03:18 +09:00
Nobuyoshi Nakada f9d0778fca
Removed MakeMakefile::C
It is exposed to the topleven namespace via included MakeMakefile.
2019-09-18 22:53:23 +09:00
Nobuyoshi Nakada 9bd77d7cf3
Removed a debug print [ci skip] 2019-09-18 22:53:22 +09:00