Description of problem: I noticed that the gcc complains "gcc: fatal error: environment variable ‘RPM_ARCH’ not defined" with the `/usr/lib/rpm/redhat/redhat-package-notes` file when running the command below on Fedora rawhide. ``` <mock-chroot> sh-5.2$ gem install byebug Fetching byebug-11.1.3.gem WARNING: You don't have /builddir/bin in your PATH, gem executables will not run. Building native extensions. This could take a while... ERROR: Error installing byebug: ERROR: Failed to build gem native extension. current directory: /builddir/.local/share/gem/ruby/gems/byebug-11.1.3/ext/byebug /usr/bin/ruby -I /usr/share/rubygems extconf.rb creating Makefile current directory: /builddir/.local/share/gem/ruby/gems/byebug-11.1.3/ext/byebug make DESTDIR\= sitearchdir\=./.gem.20221111-28-532wpi sitelibdir\=./.gem.20221111-28-532wpi clean rm -f rm -fr byebug.so false *.o *.bak mkmf.log .*.time current directory: /builddir/.local/share/gem/ruby/gems/byebug-11.1.3/ext/byebug make DESTDIR\= sitearchdir\=./.gem.20221111-28-532wpi sitelibdir\=./.gem.20221111-28-532wpi gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -fPIC -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -m64 -o breakpoint.o -c breakpoint.c gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -fPIC -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -m64 -o byebug.o -c byebug.c gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -fPIC -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -m64 -o context.o -c context.c gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -fPIC -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -m64 -o locker.o -c locker.c gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -fPIC -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -m64 -o threads.o -c threads.c rm -f byebug.so gcc -shared -o byebug.so breakpoint.o byebug.o context.o locker.o threads.o -L. -L/usr/lib64 -L. -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes -m64 -lruby -lm -lpthread -lc gcc: fatal error: environment variable ‘RPM_ARCH’ not defined compilation terminated. make: *** [Makefile:266: byebug.so] Error 1 make failed, exit code 2 ``` ``` <mock-chroot> sh-5.2$ grep -r RPM_ARCH /usr/lib/rpm/redhat /usr/lib/rpm/redhat/redhat-package-notes:+ --package-metadata={\"type\":\"rpm\",\"name\":\"%:getenv(RPM_PACKAGE_NAME \",\"version\":\"%:getenv(RPM_PACKAGE_VERSION -%:getenv(RPM_PACKAGE_RELEASE \",\"architecture\":\"%:getenv(RPM_ARCH \",\"osCpe\":\"cpe:/o:fedoraproject:fedora:38\"})))) <mock-chroot> sh-5.2$ rpm -qf /usr/lib/rpm/redhat/redhat-package-notes package-notes-srpm-macros-0.5-6.fc38.noarch <mock-chroot> sh-5.2$ rpm -q rpm rpm-4.18.0-3.fc38.x86_64 <mock-chroot> sh-5.2$ rpm -q redhat-rpm-config redhat-rpm-config-233-1.fc38.noarch ``` Version-Release number of selected component (if applicable): package-notes-srpm-macros-0.5-6.fc38.noarch How reproducible: Steps to Reproduce: 1. Build ruby.spec on the https://src.fedoraproject.org/rpms/ruby/tree/private-ruby-3.2 . 2. Install the built RPMs. 3. Run the `gem install byebug` on the mock environment by a user "mockbuild". Actual results: The `gem install byebug` failed with the error message above. Expected results: The `gem install byebug` succeeds. Additional info: It seems that the RPM_ARCH was added on the package-notes-srpm-macros-0.5 on the commit below. https://src.fedoraproject.org/rpms/package-notes/c/9da9df8af2bee3984434bba55df378d4a890dc1e
Here is a minimal reproducer. ``` <mock-chroot> sh-5.2$ cat main.c int main(int argc, char *argv[]) { return 0; } <mock-chroot> sh-5.2$ rpm -q gcc gcc-12.2.1-3.fc38.x86_64 <mock-chroot> sh-5.2$ rpm -qf /usr/lib/rpm/redhat/redhat-package-notes package-notes-srpm-macros-0.5-6.fc38.noarch <mock-chroot> sh-5.2$ gcc -specs=/usr/lib/rpm/redhat/redhat-package-notes main.c gcc: fatal error: environment variable ‘RPM_ARCH’ not defined compilation terminated. ``` The reason why the `gem install byebug (a Ruby native extension)` is using the flags defined in the redhat-rpm-config macro is because Ruby language propagates the build flags to build the native extension gem package. I checked the document in the redhat-rpm-config, and maybe I found the workaround to avoid using `-specs=/usr/lib/rpm/redhat/redhat-package-notes`. But I want to know why this happens, and what I am missing. https://src.fedoraproject.org/rpms/redhat-rpm-config//blob/rawhide/f/buildflags.md - Package note on ELF objects ``` %undefine _package_note_file ```
> Steps to Reproduce: > 1. Build ruby.spec on the https://src.fedoraproject.org/rpms/ruby/tree/private-ruby-3.2 . > 2. Install the built RPMs. > 3. Run the `gem install byebug` on the mock environment by a user "mockbuild". This also happens on the current latest rawhide branch `79d75fdcddac78d2c73000a6ae7569eabb05f7bc` too. ``` $ rpm -q ruby ruby-3.1.2-170.fc38.x86_64 ```
I found the grass package faced a similar issue with this. grass - RPM ARCH not defined https://bugzilla.redhat.com/show_bug.cgi?id=2138373 Here is how they fixed. https://src.fedoraproject.org/rpms/grass/c/65f12df9df7515907a074ea20e2c240369296fcb?branch=rawhide
It seems that here is the original ticket about this issue. Package notes break extension modules of Ruby, Haskell, and possibly more language ecosystems https://bugzilla.redhat.com/show_bug.cgi?id=2043092
I hit this error on the libarchive upstreamed test as well [1]. I've tried a similar fix as grass use and it didn't help me with this error. [1] https://src.fedoraproject.org/tests/libarchive/blob/main/f/Sanity/Basic-sanity-test-for-libarchive
This bug appears to have been reported against 'rawhide' during the Fedora Linux 38 development cycle. Changing version to 38.
(In reply to Jun Aruga from comment #0) > I noticed that the gcc complains "gcc: fatal error: environment variable > ‘RPM_ARCH’ not defined" with the `/usr/lib/rpm/redhat/redhat-package-notes` > file when running the command below on Fedora rawhide. This variable is define by rpm in builds, appropriately for the package being built. But when 'mock --shell' is used, those variables are not set. This causes problems when trying to repeat some part of the build commands, but it is not actually a problem in "real" builds. (In reply to Jun Aruga from comment #3) > I found the grass package faced a similar issue with this. > > grass - RPM ARCH not defined > Confidentialhttps://bugzilla.redhat.com/show_bug.cgi?id=2138373 > Here is how they fixed. > https://src.fedoraproject.org/rpms/grass/c/ > 65f12df9df7515907a074ea20e2c240369296fcb?branch=rawhide That fix is wrong. > Steps to Reproduce: > 1. Build ruby.spec on the > https://src.fedoraproject.org/rpms/ruby/tree/private-ruby-3.2 . > 2. Install the built RPMs. > 3. Run the `gem install byebug` on the mock environment by a user > "mockbuild". > > Actual results: > The `gem install byebug` failed with the error message above. This is the same issue as #1284684. There were various attempts to fix this, but it really needs to be resolved by the maintainers of the package in the way that they like. https://src.fedoraproject.org/rpms/ruby/pull-request/110 had a working solution, but it wasn't accepted because of some stylistic issues and whatnot. *** This bug has been marked as a duplicate of bug 1284684 ***