Bug 1548119 - crash: Partial injection of Fedora build flags
Summary: crash: Partial injection of Fedora build flags
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: crash
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Dave Anderson
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: Fedora28BuildFlags
TreeView+ depends on / blocked
 
Reported: 2018-02-22 18:55 UTC by Florian Weimer
Modified: 2018-02-23 19:10 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-23 14:49:36 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Florian Weimer 2018-02-22 18:55:46 UTC
/usr/bin/crash in crash-7.2.1-1.fc28.x86_64 was not linked with the standard Fedora linker flags (LDFLAGS) from redhat-rpm-config:

gcc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -mcet -fcf-protection      \
	-o ../../crash ../../crashlib.a amd64-tdep.o amd64-linux-tdep.o i386-tdep.o i387-tdep.o i386-linux-tdep.o glibc-tdep.o solib-svr4.o symfile-mem.o linux-tdep.o linux-record.o ser-base.o ser-unix.o ser-pipe.o ser-tcp.o inf-ptrace.o fork-child.o i386-nat.o amd64-nat.o amd64-linux-nat.o linux-nat.o linux-osdata.o proc-service.o linux-thread-db.o linux-fork.o linux-procfs.o linux-ptrace.o linux-btrace.o remote.o dcache.o tracepoint.o ax-general.o ax-gdb.o remote-fileio.o remote-notif.o  cli-dump.o cli-decode.o cli-script.o cli-cmds.o cli-setshow.o cli-logging.o cli-interp.o cli-utils.o mi-out.o mi-console.o mi-cmds.o mi-cmd-catch.o mi-cmd-env.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o mi-cmd-file.o mi-cmd-disas.o mi-symbol-cmds.o mi-cmd-target.o mi-cmd-info.o mi-interp.o mi-main.o mi-parse.o mi-getopt.o tui-command.o tui-data.o tui-disasm.o tui-file.o tui-hooks.o tui-interp.o tui-io.o tui-layout.o tui-out.o tui-regs.o tui-source.o tui-stack.o tui-win.o tui-windata.o tui-wingeneral.o tui-winsource.o tui.o python.o py-value.o py-prettyprint.o py-auto-load.o elfread.o stap-probe.o posix-hdep.o c-exp.o cp-name-parser.o ada-exp.o jv-exp.o f-exp.o go-exp.o m2-exp.o p-exp.o version.o annotate.o addrmap.o auto-load.o auxv.o agent.o bfd-target.o blockframe.o breakpoint.o break-catch-sig.o findvar.o regcache.o cleanups.o charset.o continuations.o corelow.o disasm.o dummy-frame.o dfp.o source.o value.o eval.o valops.o valarith.o valprint.o printcmd.o block.o symtab.o psymtab.o symfile.o symmisc.o linespec.o dictionary.o infcall.o infcmd.o infrun.o expprint.o environ.o stack.o thread.o exceptions.o filesystem.o inf-child.o interps.o minidebug.o main.o macrotab.o macrocmd.o macroexp.o macroscope.o mi-common.o event-loop.o event-top.o inf-loop.o completer.o gdbarch.o arch-utils.o gdbtypes.o gdb_bfd.o gdb_obstack.o osabi.o copying.o memattr.o mem-break.o target.o parse.o language.o buildsym.o findcmd.o std-regs.o signals.o exec.o reverse.o bcache.o objfiles.o observer.o minsyms.o maint.o demangle.o dbxread.o coffread.o coff-pe-read.o dwarf2read.o mipsread.o stabsread.o corefile.o dwarf2expr.o dwarf2loc.o dwarf2-frame.o dwarf2-frame-tailcall.o ada-lang.o c-lang.o d-lang.o f-lang.o objc-lang.o ada-tasks.o ada-varobj.o ui-out.o cli-out.o varobj.o vec.o go-lang.o go-valprint.o go-typeprint.o jv-lang.o jv-valprint.o jv-typeprint.o m2-lang.o opencl-lang.o p-lang.o p-typeprint.o p-valprint.o sentinel-frame.o complaints.o typeprint.o ada-typeprint.o c-typeprint.o f-typeprint.o m2-typeprint.o ada-valprint.o c-valprint.o cp-valprint.o d-valprint.o f-valprint.o m2-valprint.o serial.o mdebugread.o top.o utils.o ui-file.o user-regs.o frame.o frame-unwind.o doublest.o frame-base.o inline-frame.o gnu-v2-abi.o gnu-v3-abi.o cp-abi.o cp-support.o cp-namespace.o reggroups.o regset.o trad-frame.o tramp-frame.o solib.o solib-target.o prologue-value.o memory-map.o memrange.o xml-support.o xml-syscall.o xml-utils.o target-descriptions.o target-memory.o xml-tdesc.o xml-builtin.o inferior.o osdata.o gdb_usleep.o record.o record-full.o gcore.o gdb_vecs.o jit.o progspace.o skip.o probe.o common-utils.o buffer.o ptid.o gdb-dlfcn.o common-agent.o format.o registry.o btrace.o record-btrace.o inflow.o    init.o \
	   -lreadline ../opcodes/libopcodes.a ../bfd/libbfd.a  ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a    -ldl -lncurses -lz -lm   ../libiberty/libiberty.a  build-gnulib/import/libgnu.a -ldl -Wl,--dynamic-list=./proc-service.list  -lz -llzo2 -lsnappy -ldl -rdynamic

CFLAGS are there, but LDFLAGS are missing.

See https://src.fedoraproject.org/rpms/redhat-rpm-config/blob/master/f/buildflags.md for information on RPM macros and environment variables provided by the build environment.

Comment 1 Dave Anderson 2018-02-22 20:49:55 UTC
My crash.spec %build section currently consists of just this:

  %build
  make RPMPKG="%{version}-%{release}" CFLAGS="%{optflags}"

I read the referenced buildflags.md page, and tried this first:

  %build
  make RPMPKG="%{version}-%{release}" CFLAGS="%{optflags}" LDFLAGS="%{build_ldflags}"

And the build fails during configuration like so:
  
  ...
  checking for gcc... gcc
  checking for C compiler default output file name... 
  configure: error: in `/root/rpmbuild/BUILD/crash-7.2.1/gdb-7.6':
  configure: error: C compiler cannot create executables
  See `config.log' for more details.
  make[2]: *** No targets specified and no makefile found.  Stop.
  
  crash build failed
  ...
  
Checking the config.log, it shows this, where "%{build_ldflags}" is
being referenced literally:

...
configure:4232: checking for C compiler default output file name
configure:4254: gcc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic  %{build_ldflags} conftest.c  >&5
gcc: error: %{build_ldflags}: No such file or directory
...

It translates the CFLAGS="%{optflags}" OK, but not "%{build_ldflags}".
I don't understand why?

Comment 2 Dave Anderson 2018-02-22 20:58:09 UTC
BTW, I did the build above on a freshly-provisioned beaker machine 
(Red Hat internal), where I selected the "Fedorarawhide" family.

Comment 3 Florian Weimer 2018-02-22 21:03:36 UTC
(In reply to Dave Anderson from comment #1)
> Checking the config.log, it shows this, where "%{build_ldflags}" is
> being referenced literally:

Then the build root is too old.  You need quite a recent Fedora 28 or Rawhide compose, with at least version 94 of redhat-rpm-config.  It works in the Fedora buildroots, and the Fedora mirrors have this version as well (so mock should work out of the box).

I don't know what happens in Beaker.  I suspect it's lagging Fedora by a couple of weeks.

Comment 4 Dave Anderson 2018-02-22 21:14:00 UTC
> I don't know what happens in Beaker.  I suspect it's lagging Fedora by a couple > of weeks.

Ah, OK, it's much older than that:

  # rpm -qa | grep redhat-rpm-config
  redhat-rpm-config-67-1.module_6faa4f4e.noarch
  #

That package was built on 2017-08-15 17:23:13.

Thanks,
  Dave

Comment 5 Florian Weimer 2018-02-22 21:16:44 UTC
(In reply to Dave Anderson from comment #4)
> > I don't know what happens in Beaker.  I suspect it's lagging Fedora by a couple > of weeks.
> 
> Ah, OK, it's much older than that:
> 
>   # rpm -qa | grep redhat-rpm-config
>   redhat-rpm-config-67-1.module_6faa4f4e.noarch
>   #
> 
> That package was built on 2017-08-15 17:23:13.

I recommend to install Fedora 27, make sure the installation is current with regards to updates (basically, “dnf update”), and use “mock -r fedora-rawhide-x86_64” (or your preferred architecture), instead of building on a rawhide host.

Comment 6 Dave Anderson 2018-02-22 21:25:41 UTC
Currently I'm doing a fedpkg scratch build in the master branch.
That should work, right?

Comment 7 Dave Anderson 2018-02-22 21:42:41 UTC
> Currently I'm doing a fedpkg scratch build in the master branch.
> That should work, right?

That worked:

  Information for task build (rawhide, crash-7.2.1-2.fc29.src.rpm)
  https://koji.fedoraproject.org/koji/taskinfo?taskID=25241015

Comment 8 Dave Anderson 2018-02-23 14:49:36 UTC
Information for build crash-7.2.1-2.fc29
https://koji.fedoraproject.org/koji/buildinfo?buildID=1049079

Comment 9 Florian Weimer 2018-02-23 19:10:58 UTC
Thanks, confirmed as fixed.  I pushed the change to Fedora 28, too.


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