[#109095] [Ruby master Misc#18888] Migrate ruby-lang.org mail services to Google Domains and Google Workspace — "shugo (Shugo Maeda)" <noreply@...>
Issue #18888 has been reported by shugo (Shugo Maeda).
16 messages
2022/06/30
[ruby-core:108963] [Ruby master Misc#18691] An option to run `make rbconfig.rb` in a different directory
From:
"jaruga (Jun Aruga)" <noreply@...>
Date:
2022-06-16 16:59:13 UTC
List:
ruby-core #108963
Issue #18691 has been updated by jaruga (Jun Aruga).
> So, I want to add the ARCH_FLAG to configure script environment variables for convenience.
Just note. I tried to implement build only flags to inject ARCH_FLAG in Makefile with the patch below (the latest commit on <https://github.com/junaruga/ruby/commits/wip/configure-arch-flag>)
```
diff --git a/configure.ac b/configure.ac
index aef679296d..5ab8b05453 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,6 +49,7 @@ m4_include([tool/m4/ruby_werror_flag.m4])dnl
AC_ARG_VAR([cflags], [additional CFLAGS (ignored when CFLAGS is given)])dnl
AC_ARG_VAR([cppflags], [additional CPPFLAGS (ignored when CPPFLAGS is given)])dnl
AC_ARG_VAR([cxxflags], [additional CXXFLAGS (ignored when CXXFLAGS is given)])dnl
+AC_ARG_VAR([build_only_flags], [build only flags, not used in the rbconfig.rb])dnl
: "environment section" && {
HAVE_BASERUBY=yes
@@ -2894,6 +2895,7 @@ AC_ARG_WITH(mjit-tabs,
AC_SUBST(MJIT_TABS)dnl
AC_SUBST(DLDFLAGS)dnl
AC_SUBST(ARCH_FLAG)dnl
+AC_SUBST(build_only_flags)dnl
AC_SUBST(MJIT_HEADER_FLAGS)dnl
AC_SUBST(MJIT_HEADER_INSTALL_DIR)dnl
AC_SUBST(MJIT_CC)dnl
@@ -4411,6 +4413,7 @@ config_summary "DLDFLAGS" "$DLDFLAGS"
config_summary "optflags" "$optflags"
config_summary "debugflags" "$debugflags"
config_summary "warnflags" "$warnflags"
+config_summary "build_only_flags" "$build_only_flags"
config_summary "strip command" "$STRIP"
config_summary "install doc" "$DOCTARGETS"
config_summary "JIT support" "$MJIT_SUPPORT"
diff --git a/template/Makefile.in b/template/Makefile.in
index a8581260b9..9628fdac46 100644
--- a/template/Makefile.in
+++ b/template/Makefile.in
@@ -81,7 +81,7 @@ CC_VERSION = @CC_VERSION@
OUTFLAG = @OUTFLAG@$(empty)
COUTFLAG = @COUTFLAG@$(empty)
CPPOUTFLAG = >
-ARCH_FLAG = @ARCH_FLAG@
+ARCH_FLAG = @ARCH_FLAG@ @build_only_flags@
CFLAGS_NO_ARCH = @CFLAGS@
CFLAGS = $(CFLAGS_NO_ARCH) $(ARCH_FLAG)
cflags = @cflags@
```
Then I tested like this.
```
$ ./autogen.sh
$ CFLAGS='-O2' build_only_flags="--specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1" ./configure --prefix=$(pwd)/dest/ruby --enable-shared --enable-mkmf-verbose | tee configure.log
...
* build_only_flags: --specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 \
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1
...
$ vi build_only_flags config.status
...
S["build_only_flags"]="--specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1"
...
$ grep ^ARCH_FLAG Makefile
ARCH_FLAG = --specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1
$ make V=1 2>&1 | tee make.log
$ make install 2>&1 | tee make_install.log
```
The command below works. The command with explicit `ARCH_FLAG` propagates the value to the bundled native extension gem's compile (gcc).
```
$ make install V=1 ARCH_FLAG="--specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1" 2>&1 | tee make_install.log
$ vi make_install.log
...
./miniruby -I./lib -I. -I.ext/common ./ext/extmk.rb --make='make' \
--command-output=.bundle/gems/debug-1.5.0/exts.mk --dest-dir="" --extout=".ext" --ext-build-dir="./ext" --mflags="" --make-flags=" -- ARCH_FLAG=--specs=/usr/lib/rpm/redhat/redhat-hardened-cc1\ -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 V=1" --gnumake=yes --extflags="" --make-flags="MINIRUBY='./miniruby -I./lib -I. -I.ext/common '" --no-extstatic \
-- configure .bundle/gems/debug-1.5.0
...
$ vi dest/ruby/lib/ruby/gems/3.2.0+1/extensions/x86_64-linux/3.2.0+1/debug-1.5.0/gem_make.out
...
gcc -I. -I/home/jaruga/git/ruby/ruby/dest/ruby/include/ruby-3.2.0+1/x86_64-linux -I/home/jaruga/git/ruby/ruby/dest/ruby/include/ruby-3.2.0+1/ruby/backward -I/home/jaruga/git/ruby/ruby/dest/ruby/include/ruby-3.2.0+1 -I. -DHAVE_RB_ISEQ_PARAMETERS -DHAVE_RB_ISEQ_CODE_LOCATION -DHAVE_RB_ISEQ_TYPE -fPIC -O2 -fPIC --specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -o debug.o -c debug.c
...
```
The command below doesn't work. It doesn't work without the make argument `ARCH_FLAG`. I expected the line `ARCH_FLAG = --specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1` is used.
```
$ make install V=1 ECHO=echo Q= 2>&1 | tee make_install.log
$ vi make_install.log
...
./miniruby -I./lib -I. -I.ext/common ./ext/extmk.rb --make='make' \
--command-output=.bundle/gems/debug-1.5.0/exts.mk --dest-dir="" --extout=".ext" --ext-build-dir="./ext" --mflags="" --make-flags=" -- Q= ECHO=echo V=1" --gnumake=yes --extflags="" --make-flags="MINIRUBY='./miniruby -I./lib -I. -I.ext/common '" --no-extstatic \
-- configure .bundle/gems/debug-1.5.0
...
$ vi dest/ruby/lib/ruby/gems/3.2.0+1/extensions/x86_64-linux/3.2.0+1/debug-1.5.0/gem_make.out
...
gcc -I. -I/home/jaruga/git/ruby/ruby/dest/ruby/include/ruby-3.2.0+1/x86_64-linux -I/home/jaruga/git/ruby/ruby/dest/ruby/include/ruby-3.2.0+1/ruby/backward -I/home/jaruga/git/ruby/ruby/dest/ruby/include/ruby-3.2.0+1 -I. -DHAVE_RB_ISEQ_PARAMETERS -DHAVE_RB_ISEQ_CODE_LOCATION -DHAVE_RB_ISEQ_TYPE -fPIC -O2 -fPIC -o debug.o -c debug.c
...
```
I added the `ARCH_FLAG` to the `SCRIPT_ARGS` used to compile bundled gems. However the command below also doesn't work. The `ARCH_FLAG` was not used in the `dest/ruby/lib/ruby/gems/3.2.0+1/extensions/x86_64-linux/3.2.0+1/debug-1.5.0/gem_make.out`.
uncommon.mk
```
SCRIPT_ARGS = --dest-dir="$(DESTDIR)" \
--extout="$(EXTOUT)" \
--ext-build-dir="./ext" \
--mflags="$(MFLAGS)" \
--make-flags="$(MAKEFLAGS) ARCH_FLAG=\"$(ARCH_FLAG)\""
```
```
$ make install V=1 ECHO=echo Q= 2>&1 | tee make_install.log
$ vi make_install.log
...
./miniruby -I./lib -I. -I.ext/common ./ext/extmk.rb --make='make' \
--command-output=.bundle/gems/debug-1.5.0/exts.mk --dest-dir="" --extout=".ext" --ext-build-dir="./ext" --mflags="" --make-flags=" -- Q= ECHO=echo V=1 ARCH_FLAG=\"--specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1\"" --gnumake=yes --extflags="" --make-flags="MINIRUBY='./miniruby -I./lib -I. -I.ext/common '" --no-extstatic \
-- configure .bundle/gems/debug-1.5.0
...
$ vi dest/ruby/lib/ruby/gems/3.2.0+1/extensions/x86_64-linux/3.2.0+1/debug-1.5.0/gem_make.out
...
gcc -I. -I/home/jaruga/git/ruby/ruby/dest/ruby/include/ruby-3.2.0+1/x86_64-linux -I/home/jaruga/git/ruby/ruby/dest/ruby/include/ruby-3.2.0+1/ruby/backward -I/home/jaruga/git/ruby/ruby/dest/ruby/include/ruby-3.2.0+1 -I. -DHAVE_RB_ISEQ_PARAMETERS -DHAVE_RB_ISEQ_CODE_LOCATION -DHAVE_RB_ISEQ_TYPE -fPIC -O2 -fPIC -o debug.o -c debug.c
...
```
----------------------------------------
Misc #18691: An option to run `make rbconfig.rb` in a different directory
https://bugs.ruby-lang.org/issues/18691#change-98064
* 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/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>