Bug 2336272 - gcc with -specs=/usr/lib/rpm/redhat/redhat-package-notes ICE gcc.cc:3260 with newline in env
Summary: gcc with -specs=/usr/lib/rpm/redhat/redhat-package-notes ICE gcc.cc:3260 with...
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 41
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2025-01-07 23:24 UTC by Daniel Black
Modified: 2025-01-07 23:24 UTC (History)
12 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Daniel Black 2025-01-07 23:24:29 UTC
When RPM_PACKAGE_RELEASE as an env variable, used by /usr/lib/rpm/redhat/redhat-package-notes contains a new line, compiling with  -specs=/usr/lib/rpm/redhat/redhat-package-notes as a linker option cases an internal compile error.

        : && /usr/bin/c++   CMakeFiles/cmTC_16a53.dir/src.cxx.o -o cmTC_16a53  -specs=/usr/lib/rpm/redhat/redhat-package-notes && :
        c++: internal compiler error: in execute, at gcc.cc:3260

$ g++ --version
g++ (GCC) 14.2.1 20240912 (Red Hat 14.2.1-3)

Reproducible: Always

Steps to Reproduce:
1.CMakeLists.txt file of

cmake_minimum_required(VERSION 3.10)
project(MyProject)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)

SET(ENV{RPM_PACKAGE_NAME}    MyExecutable)
SET(ENV{RPM_ARCH}            x86_64)
SET(ENV{RPM_PACKAGE_VERSION} 11.11.1)
EXECUTE_PROCESS(COMMAND rpm --eval "1%{?dist}" OUTPUT_VARIABLE RPM_PACKAGE_RELEASE_EXPANDED)

# To avoid ICE
# STRING(STRIP "${RPM_PACKAGE_RELEASE_EXPANDED}" RPM_PACKAGE_RELEASE_EXPANDED)

SET(ENV{RPM_PACKAGE_RELEASE} ${RPM_PACKAGE_RELEASE_EXPANDED})

EXECUTE_PROCESS(COMMAND "env" OUTPUT_VARIABLE ENV_IS_THIS ECHO_OUTPUT_VARIABLE)

include(CheckCXXSourceCompiles)
SET(CMAKE_REQUIRED_LIBRARIES -specs=/usr/lib/rpm/redhat/redhat-package-notes)
CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }"  THIS_BREAKS)


2. cmake 
.
(appoligies for cmake example, shell attempts seem to be consuming the newline)
Actual Results:  
RPM_PACKAGE_NAME=MyExecutable
RPM_ARCH=x86_64
RPM_PACKAGE_VERSION=11.11.1
RPM_PACKAGE_RELEASE=1.fc41

-- Performing Test THIS_BREAKS
-- Performing Test THIS_BREAKS - Failed
-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/dan/repos/build-gcc-bug-packge-notes


$ cat CMakeFiles/CMakeConfigureLog.yaml 

events:
  -
    kind: "try_compile-v1"
    backtrace:
      - "/usr/share/cmake/Modules/Internal/CheckSourceCompiles.cmake:101 (try_compile)"
      - "/usr/share/cmake/Modules/CheckCXXSourceCompiles.cmake:52 (cmake_check_source_compiles)"
      - "CMakeLists.txt:20 (CHECK_CXX_SOURCE_COMPILES)"
    checks:
      - "Performing Test THIS_BREAKS"
    directories:
      source: "/home/dan/repos/build-gcc-bug-packge-notes/CMakeFiles/CMakeScratch/TryCompile-3n09BL"
      binary: "/home/dan/repos/build-gcc-bug-packge-notes/CMakeFiles/CMakeScratch/TryCompile-3n09BL"
    cmakeVariables:
      CMAKE_CXX_FLAGS: ""
      CMAKE_CXX_FLAGS_DEBUG: "-g"
      CMAKE_EXE_LINKER_FLAGS: ""
    buildResult:
      variable: "THIS_BREAKS"
      cached: true
      stdout: |
        Change Dir: '/home/dan/repos/build-gcc-bug-packge-notes/CMakeFiles/CMakeScratch/TryCompile-3n09BL'
        
        Run Build Command(s): /usr/bin/ninja-build -v cmTC_c168c
        [1/2] /usr/bin/c++ -DTHIS_BREAKS  -std=gnu++14 -o CMakeFiles/cmTC_c168c.dir/src.cxx.o -c /home/dan/repos/build-gcc-bug-packge-notes/CMakeFiles/CMakeScratch/TryCompile-3n09BL/src.cxx
        [2/2] : && /usr/bin/c++   CMakeFiles/cmTC_c168c.dir/src.cxx.o -o cmTC_c168c  -specs=/usr/lib/rpm/redhat/redhat-package-notes && :
        FAILED: cmTC_c168c 
        : && /usr/bin/c++   CMakeFiles/cmTC_c168c.dir/src.cxx.o -o cmTC_c168c  -specs=/usr/lib/rpm/redhat/redhat-package-notes && :
        c++: internal compiler error: in execute, at gcc.cc:3260
        Please submit a full bug report, with preprocessed source (by using -freport-bug).
        See <http://bugzilla.redhat.com/bugzilla> for instructions.
        ninja: build stopped: subcommand failed.
        
      exitCode: 1

Expected Results:  
-- Performing Test THIS_BREAKS
-- Performing Test THIS_BREAKS - Success
-- Configuring done (0.5s)
-- Generating done (0.0s)
-- Build files have been written to: /home/dan/repos/build-gcc-bug-packge-notes


Note You need to log in before you can comment on or make changes to this bug.