summaryrefslogtreecommitdiff
path: root/lib/mkmf.rb
AgeCommit message (Collapse)Author
2025-12-14[DOC] Fix link in MakeMakefileBurdetteLamar
2025-10-03Use LSAN_OPTIONS instead of ASAN_OPTIONS in mkmfPeter Zhu
Newer versions of clang's LSAN uses LSAN_OPTIONS environment variable instead of ASAN_OPTIONS.
2025-07-31Suppress maybe-uninitialized warningsNobuyoshi Nakada
2025-05-12Copy to path with the base nameNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13302
2025-04-13Fix unnecessary `false` in `CLEANLIBS`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13107
2025-01-14[DOC] About `create_makefile`Nobuyoshi Nakada
Describe two features that were missing from the documentation: - yields configuration part if a block is given. - "depend" file will be included. Notes: Merged: https://github.com/ruby/ruby/pull/12571
2024-12-23Use the dedicated constants `LIBARG` and `LIBPATHFLAG`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/9815
2024-12-23Implements [Feature #3456]: Support pkgconf on windowsJulien Marrec
1. Store the `PKG_CONFIG` variable in Makefile.sub (or try to get it from the ENV var PKG_CONFIG in mkmf.rb) 2. Try to use --msvc-syntax, with a fallback to replacing -Lxxx with -libpath:xxx. --msvc-syntax has been in pkgconf since 1.4.0 (released 7 years ago). pkg-config (freedesktop), does not support it, hence the fallback. 3. The `try_ldflags` passes these `ldflags` as the `opt` parameter to the `link_command`, not as `ldflags`. Unix systems are forgiving in that regard, MSVC is not: as a result as passing them as `opt`, they (specifically the `/libpath:xxx` ones) end up passed before the `-link` command to `cl.exe` and it throws because it ignores it and therefore can't find the lib. ``` cl : Command line warning D9002 : ignoring unknown option '-libpath:C:/Users/julien/.conan2/p/libff3726d89a6255c/p/lib' ``` Notes: Merged: https://github.com/ruby/ruby/pull/9815
2024-09-29Remove leading spaces from `LIBPATHFLAG` and `RPATHFLAG`Nobuyoshi Nakada
Join with a space in `MakeMakefile#libpathflag` instead. Notes: Merged: https://github.com/ruby/ruby/pull/11724
2024-04-02[Feature #20345] Add `--target-rbconfig` option to mkmfYuta Saito
Introduce a new mkmf option `--target-rbconfig` to specify the RbConfig file for the deployment target platform. This option is useful for cross-compiling Ruby extensions without faking the global top-level `RbConfig` constant.
2024-03-10Clean intermediate files and debug info for each targetNobuyoshi Nakada
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-05Reapply "mkmf.rb: Define missing `POSTLINK` variable in generated Makefile"Hiroshi SHIBATA
This reverts commit 0ae0a0c1c3bb01d118c5a924d731a2b3e9774105.
2024-03-05Revert "mkmf.rb: Define missing `POSTLINK` variable in generated Makefile"Hiroshi SHIBATA
This reverts commit 71d511615b8dac459d6f88f5896b9859f99c999e.
2024-03-02mkmf.rb: Define missing `POSTLINK` variable in generated MakefileYuta Saito
The `POSTLINK` variable had been used in the `LINK_SO` variable, which is used to link shared extension libraries. However, the `POSTLINK` variable had not been defined in the generated Makefile, so extension libraries were not properly post-processed. It was not a critical issue for the existing `POSTLINK` usage for darwin platforms, but it would be a problem for Wasm/WASI platform, which requires *mandatory* post-processing for shared extension libraries.
2024-03-01Use configured `LD` for linking enc and ext librariesYuta Saito
"AR" was well propagated to the enc.mk and mkmf, but "LD" was not. This caused the dynamic libraries to be linked with a linker found in the PATH, which could be different from the one used in the Ruby build process. This is especially important for cross-compilation, where the host linker may not be compatible with the target system. (e.g. WebAssembly)
2024-02-12Burn default ASAN options into the built RubyKJ Tsanaktsidis
* We always need use_sigaltstack=0 because Ruby registers sigaltstack handlers * We also need to disable leak detection (unless RUBY_FREE_AT_EXIT is set - I might experiment later with automatically enabling leak detection if RUBY_FREE_AT_EXIT is set). Burning it into the built ruby binary in this way avoids people needing to remember to start their Ruby program with these flags all the time. We also need a small fix in mkmf to make sure that test programs also don't have leak detection enabled (this is never desirable) [Bug #20256]
2024-01-10mkmf.rb: use kwargsNobuyoshi Nakada
2024-01-08Add `MakeMakefile["C"]`Nobuyoshi Nakada
2024-01-07[DOC] Documentation of mkmf.rbNobuyoshi Nakada
2024-01-06Too much nestings make editors confusedNobuyoshi Nakada
Get rid of nested double quotes inside nested interpolations. Also, remove comments that are no longer needed by the documents.
2023-10-12Fix `dir_config` cache for -include and -lib optionsNobuyoshi Nakada
Set to "--with-" options, not "--without-" keys.
2023-10-12Include default values in `dir_config` cache keysNobuyoshi Nakada
The extconf.rb in mysql2 gem repeats `dir_config('mysql')`, without and with the default path. The third call returns the former results even with the default path. Since it does not check the results of the third call, that `nil` is passed to `find_library` as a path, and fails with `NoMethodError`.
2023-07-10Allow nmake to ignore errorsNobuyoshi Nakada
cmd.exe can redirect file descriptor other than STDOUT, while command.com couldn't. Notes: Merged: https://github.com/ruby/ruby/pull/8050
2023-07-10Use `File::NULL` instead of hard coded null device namesNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/8050
2023-05-29mkmf: Add the extra option `--with-verbose` to enable verbose mode. (#7863)Jun Aruga
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> Notes: Merged-By: junaruga
2023-01-09mkmf.rb: Refine message from `pkg_config`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7088
2023-01-09mkmf.rb: Prefer `caller_locations` over parsing `caller`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7088
2023-01-06mkmf.rb: Refactor splitting configure_args and remove duplicate codeNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7076
2022-12-15[Bug #19189] Fallback to the default "pkg-config"Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6927
2022-12-05Clean compiler intermediate files moreNobuyoshi Nakada
2022-11-21Use class methods of `File` over `Kernel.open` and `IO.read`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6777
2022-10-24Set timestamp path for the target path to TARGET_SO_DIR_TIMESTAMPNobuyoshi Nakada
2022-10-02Fallback PKG_CONFIG to the configured pkg-config alwaysNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6482
2022-09-17[Bug #19005] dynamic_lookup linker option in external librariesNobuyoshi Nakada
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. Notes: Merged: https://github.com/ruby/ruby/pull/6394 Merged-By: nobu <nobu@ruby-lang.org>
2022-08-04Use $(bindir) for path to executable in mkmfAlan Wu
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... Notes: Merged: https://github.com/ruby/ruby/pull/6193
2022-08-04Link ext bundles with bundle loader option for newer ld64Yuta Saito
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 Notes: Merged: https://github.com/ruby/ruby/pull/6193
2022-05-12mkmf: Add a configure option to set verbose mode (V=1 or 0) in mkmf.rb.Jun Aruga
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 ... ``` Notes: Merged: https://github.com/ruby/ruby/pull/5879
2022-04-26Use compiled instead of compliedKaĆ­que Kandy Koga
Capitalize creates Notes: Merged: https://github.com/ruby/ruby/pull/5848
2022-04-23Remove unnecessary sortKazuhiro NISHIYAMA
Because `Dir.[]` returns the sorted results since Ruby 3.0. Notes: Merged: https://github.com/ruby/ruby/pull/5832
2022-04-05Document MakeMakefile#append_cflagsAlan Wu
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. Notes: Merged: https://github.com/ruby/ruby/pull/5760
2022-03-20[DOC] make internally used classes/methods nodocNobuyoshi Nakada
Empty class documents are generated even with `:stopdoc:`.
2022-03-17Make implicit function declaration error [Feature #18615]Nobuyoshi Nakada
Enable `-Werror=implicit-function-declaration` by default for building C extensions for early failures.
2022-01-29mkmf: unify duplicate code in pkg_configNobuyoshi Nakada
2022-01-29mkmf: pkg_config accepts multiple optionsMike Dalessio
Notes: Merged: https://github.com/ruby/ruby/pull/5436
2021-12-10Prefer flat_mapNobuyoshi Nakada
2021-11-26mkmf: take `PKG_CONFIG_PATH` from `dir_config` library pathNobuyoshi Nakada
So that version dependent pkg-config files can override files in the default locations. Notes: Merged: https://github.com/ruby/ruby/pull/5182
2021-11-26mkmf: deal with environment variables in MakeMakefile#xpopenNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5182
2021-11-26mkmf: MakeMakefile#xpopen may be passed an option hashNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5182
2021-10-15Make explicit opening filesNobuyoshi Nakada
2021-10-03Revert "mkmf.rb: try linking at try_var" [Bug #18235]Nobuyoshi Nakada
This reverts commit 524513be399e81bb170ec88aa0d501f33cbde8c3, which can return false positive by existing but unusable symbol, including functions.