ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "jaruga (Jun Aruga)" <noreply@ruby-lang.org>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:108472] [Ruby master Misc#18691] An option to run `make rbconfig.rb` in a different directory
Date: Wed, 04 May 2022 17:54:21 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-97511.20220504175421.11018@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-18691.20220412164453.11018@ruby-lang.org

Issue #18691 has been updated by jaruga (Jun Aruga).


A little related to this ticket, I sent PR to set `V = 1` in `mkmf.rb` by `configure --enable-mkmf-verbose`.
https://github.com/ruby/ruby/pull/5879


----------------------------------------
Misc #18691: An option to run `make rbconfig.rb` in a different directory
https://bugs.ruby-lang.org/issues/18691#change-97511

* Author: jaruga (Jun Aruga)
* Status: Feedback
* Priority: Normal
----------------------------------------
In a Fedora Ruby RPM packaging, I have a challenge for the current `make rbconfig.rb`. Currently when we build Ruby from source to create the Ruby RPM package, we set compiler flag `CFLAGS` including `--specs=/usr/lib/rpm/redhat/redhat-hardened-cc1'`. The file `/usr/lib/rpm/redhat/redhat-hardened-cc1` is managed in `redhat-rpm-config` RPM package. This is a problem when end users run `gem install <a_gem_with_native_extension>`. Because the `config.status` created by `configure` script and `rbconfig.rb` created by `make` (`make rbconfig`) includes `CFLAGS` including `--specs=/usr/lib/rpm/redhat/redhat-hardened-cc1'`. And the `gem install` checks flags in `rbconfig.rb`. Then end users need to install the redhat-rpm-config RPM to run the `gem install`.

So, we want to create another `rbconfig.rb` file with flags not depending on files in the redhat-rpm-config RPM, and ship in the Ruby RPM, so that end users can run `gem install` without installing `redhat-rpm-config` RPM.

Here are ideal steps to create another `rbconfig.rb` when building Ruby to create the Ruby RPM package. I tested it on the current latest master `381475f02e6b44ae729f9403637b30c445b622e5`.

```
$ autoconf
$ CFLAGS='-O2 --specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' ./configure
$ make

$ mkdir -p build/rbconfig
$ cd build/rbconfig
$ CFLAGS='-O2' ../../configure
$ make rbconfig.rb
```

Then we can ship the `build/rbconfig/rbconfig.rb`.

But right now it seems that the `make rbconfig.rb` triggers the process to build `miniruby`, and I want to skip the process.

```
$ pwd
/home/jaruga/git/ruby/ruby/build/rbconfig

$ ls
config.log  config.status*  .ext/  GNUmakefile  Makefile  uncommon.mk

$ make rbconfig.rb
compiling ../../main.c
compiling ../../dmydln.c
...
```

I executed the following commands, to create `miniruby` on the current working directory and not to remake `miniruby` (`make -o miniruby`) to skip the process to build the `miniruby`. But ideally I want to execute only `make rbconfig` to create the `rbconfig.rb` in `build/rbconfig` directory. Do you have any idea about how to improve files such as `configure.ac`, `common.mk` or `tool/mkconfig.rb` to achieve this?

```
$ cp -p ../../miniruby .

$ make -o miniruby rbconfig.rb
/bin/sh ../../tool/ifchange "--timestamp=.rbconfig.time" rbconfig.rb rbconfig.tmp
rbconfig.rb updated

$ diff -u ../../rbconfig.rb rbconfig.rb
--- ../../rbconfig.rb	2022-04-12 18:03:45.484465916 +0200
+++ rbconfig.rb	2022-04-12 18:13:09.248334704 +0200
@@ -44,7 +44,7 @@
   CONFIG["RUBY_SEARCH_PATH"] = ""
   CONFIG["UNIVERSAL_INTS"] = ""
   CONFIG["UNIVERSAL_ARCHNAMES"] = ""
-  CONFIG["configure_args"] = " 'CFLAGS=-O2 --specs=/usr/lib/rpm/redhat/redhat-hardened-cc1'"
+  CONFIG["configure_args"] = " 'CFLAGS=-O2'"
   CONFIG["CONFIGURE"] = "configure"
   CONFIG["vendorarchdir"] = "$(vendorlibdir)/$(sitearch)"
   CONFIG["vendorlibdir"] = "$(vendordir)/$(ruby_version)"
@@ -173,7 +173,7 @@
   CONFIG["OBJEXT"] = "o"
   CONFIG["CPPFLAGS"] = " $(DEFS) $(cppflags)"
   CONFIG["LDFLAGS"] = "-L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic"
-  CONFIG["CFLAGS"] = "-O2 --specs=/usr/lib/rpm/redhat/redhat-hardened-cc1"
+  CONFIG["CFLAGS"] = "-O2"
   CONFIG["STRIP"] = "strip -S -x"
   CONFIG["RANLIB"] = "gcc-ranlib"
   CONFIG["OBJDUMP"] = "objdump"
```




-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2022-05-04 17:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 16:44 [ruby-core:108216] [Ruby master Misc#18691] An option to run `make rbconfig.rb` in a different directory jaruga (Jun Aruga)
2022-04-14  6:51 ` [ruby-core:108229] " nobu (Nobuyoshi Nakada)
2022-04-21  8:53 ` [ruby-core:108336] " jaruga (Jun Aruga)
2022-04-21 10:40 ` [ruby-core:108348] " jaruga (Jun Aruga)
2022-04-21 12:26 ` [ruby-core:108349] " jaruga (Jun Aruga)
2022-04-21 12:35 ` [ruby-core:108350] " jaruga (Jun Aruga)
2022-05-04 17:54 ` jaruga (Jun Aruga) [this message]
2022-05-09 17:34 ` [ruby-core:108496] " jaruga (Jun Aruga)
2022-06-13 17:36 ` [ruby-core:108879] " jaruga (Jun Aruga)
2022-06-13 17:49 ` [ruby-core:108880] " jaruga (Jun Aruga)
2022-06-16 16:59 ` [ruby-core:108963] " jaruga (Jun Aruga)
2022-06-29 10:03 ` [ruby-core:109093] " nobu (Nobuyoshi Nakada)
2022-06-30  8:37 ` [ruby-core:109097] " jaruga (Jun Aruga)
2022-06-30 13:20 ` [ruby-core:109103] [Ruby master Misc#18691] An option to build Ruby with build only flags not propagated to `rbconfig.rb` jaruga (Jun Aruga)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-97511.20220504175421.11018@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).