Bug 233734

Summary: Possible build race: ld: cannot find -lh_csu
Product: Base System Reporter: Li-Wen Hsu <lwhsu>
Component: miscAssignee: Ed Maste <emaste>
Status: Closed FIXED    
Severity: Affects Some People CC: Andrew, bdrewery, emaste
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   

Description Li-Wen Hsu freebsd_committer 2018-12-02 21:20:00 UTC
Failed runs:

https://ci.freebsd.org/job/FreeBSD-head-mips-build/5273/console
https://ci.freebsd.org/job/FreeBSD-head-mips64-build/5365/console

For a failed run ( https://ci.freebsd.org/job/FreeBSD-head-mips-build/5273/consoleText )

We can see only libh_csu.so.full has been built before -lh_csu is used:

$ grep h_csu consoleText
echo cxx_constructors.full: /usr/obj/usr/src/mips.mips/tmp/usr/lib/libc.a /usr/obj/usr/src/mips.mips/lib/csu/tests/dso/libh_csu.so /usr/obj/usr/src/mips.mips/tmp/usr/lib/libprivateatf-c++.a /usr/obj/usr/src/mips.mips/tmp/usr/lib/libprivateatf-c.a >> .depend.cxx_constructors
--- libh_csu.so.full ---
building shared library libh_csu.so
cc --sysroot=/usr/obj/usr/src/mips.mips/tmp -B/usr/obj/usr/src/mips.mips/tmp/usr/bin  -EB -mabi=32   -shared -Wl,-x -Wl,--fatal-warnings -Wl,--warn-shared-textrel  -o libh_csu.so.full -Wl,-soname,libh_csu.so  `NM='nm' NMFLAGS='' lorder init_test.pico fini_test.pico cxx_constructors.pico |  tsort -q`
echo init_test.full: /usr/obj/usr/src/mips.mips/tmp/usr/lib/libc.a /usr/obj/usr/src/mips.mips/lib/csu/tests/dso/libh_csu.so /usr/obj/usr/src/mips.mips/tmp/usr/lib/libprivateatf-c++.a /usr/obj/usr/src/mips.mips/tmp/usr/lib/libprivateatf-c.a >> .depend.init_test
c++ --sysroot=/usr/obj/usr/src/mips.mips/tmp -B/usr/obj/usr/src/mips.mips/tmp/usr/bin -O -pipe -DDSO_BASE -I/usr/src/lib/csu/mips -G0 -EB -mabi=32 -msoft-float -g -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wpointer-arith -Wno-uninitialized  -Wl,-rpath,/usr/tests/lib/csu/dynamiclib -L/usr/obj/usr/src/mips.mips/lib/csu/tests/dso -EB -mabi=32  -o init_test.full  init_test.o -lh_csu -lprivateatf-c++ -lprivateatf-c -lprivateatf-c
/usr/obj/usr/src/mips.mips/tmp/usr/bin/ld: cannot find -lh_csu

But for a successful run: ( https://ci.freebsd.org/job/FreeBSD-head-mips-build/5274/consoleText )

libh_csu.so has beed built before -lh_csu is used:

$ grep h_csu consoleText
--- libh_csu.so.full ---
building shared library libh_csu.so
cc --sysroot=/usr/obj/usr/src/mips.mips/tmp -B/usr/obj/usr/src/mips.mips/tmp/usr/bin  -EB -mabi=32   -shared -Wl,-x -Wl,--fatal-warnings -Wl,--warn-shared-textrel  -o libh_csu.so.full -Wl,-soname,libh_csu.so  `NM='nm' NMFLAGS='' lorder init_test.pico fini_test.pico cxx_constructors.pico |  tsort -q`
--- libh_csu.so.debug ---
objcopy --only-keep-debug libh_csu.so.full libh_csu.so.debug
--- libh_csu.so ---
objcopy --strip-debug --add-gnu-debuglink=libh_csu.so.debug  libh_csu.so.full libh_csu.so
echo cxx_constructors.full: /usr/obj/usr/src/mips.mips/tmp/usr/lib/libc.a /usr/obj/usr/src/mips.mips/lib/csu/tests/dso/libh_csu.so /usr/obj/usr/src/mips.mips/tmp/usr/lib/libprivateatf-c++.a /usr/obj/usr/src/mips.mips/tmp/usr/lib/libprivateatf-c.a >> .depend.cxx_constructors
c++ --sysroot=/usr/obj/usr/src/mips.mips/tmp -B/usr/obj/usr/src/mips.mips/tmp/usr/bin -O -pipe -DDSO_BASE -I/usr/src/lib/csu/mips -G0 -EB -mabi=32 -msoft-float -g -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wpointer-arith -Wno-uninitialized  -Wl,-rpath,/usr/tests/lib/csu/dynamiclib -L/usr/obj/usr/src/mips.mips/lib/csu/tests/dso -EB -mabi=32  -o cxx_constructors.full  cxx_constructors.o -lh_csu -lprivateatf-c++ -lprivateatf-c -lprivateatf-c
echo init_test.full: /usr/obj/usr/src/mips.mips/tmp/usr/lib/libc.a /usr/obj/usr/src/mips.mips/lib/csu/tests/dso/libh_csu.so /usr/obj/usr/src/mips.mips/tmp/usr/lib/libprivateatf-c++.a /usr/obj/usr/src/mips.mips/tmp/usr/lib/libprivateatf-c.a >> .depend.init_test
c++ --sysroot=/usr/obj/usr/src/mips.mips/tmp -B/usr/obj/usr/src/mips.mips/tmp/usr/bin -O -pipe -DDSO_BASE -I/usr/src/lib/csu/mips -G0 -EB -mabi=32 -msoft-float -g -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wpointer-arith -Wno-uninitialized  -Wl,-rpath,/usr/tests/lib/csu/dynamiclib -L/usr/obj/usr/src/mips.mips/lib/csu/tests/dso -EB -mabi=32  -o init_test.full  init_test.o -lh_csu -lprivateatf-c++ -lprivateatf-c -lprivateatf-c
echo fini_test.full: /usr/obj/usr/src/mips.mips/tmp/usr/lib/libc.a /usr/obj/usr/src/mips.mips/lib/csu/tests/dso/libh_csu.so /usr/obj/usr/src/mips.mips/tmp/usr/lib/libprivateatf-c++.a /usr/obj/usr/src/mips.mips/tmp/usr/lib/libprivateatf-c.a >> .depend.fini_test
c++ --sysroot=/usr/obj/usr/src/mips.mips/tmp -B/usr/obj/usr/src/mips.mips/tmp/usr/bin -O -pipe -DDSO_BASE -I/usr/src/lib/csu/mips -G0 -EB -mabi=32 -msoft-float -g -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wpointer-arith -Wno-uninitialized  -Wl,-rpath,/usr/tests/lib/csu/dynamiclib -L/usr/obj/usr/src/mips.mips/lib/csu/tests/dso -EB -mabi=32  -o fini_test.full  fini_test.o -lh_csu -lprivateatf-c++ -lprivateatf-c -lprivateatf-c
install -N /usr/src/etc  -s -o root -g wheel -m 444   -S  libh_csu.so /usr/obj/usr/src/mips.mips/release/dist/base/usr/tests/lib/csu/dynamiclib//
install -N /usr/src/etc  -o root -g wheel -m 444    libh_csu.so.debug /usr/obj/usr/src/mips.mips/release/dist/base/usr/lib/debug/usr/tests/lib/csu/dynamiclib//
a ./usr/tests/lib/csu/dynamiclib/libh_csu.so
a usr/lib/debug/usr/tests/lib/csu/dynamiclib/libh_csu.so.debug
Comment 4 Ed Maste freebsd_committer 2019-01-04 18:26:58 UTC
Reproducible with something like:
% cd lib/csu/tests
% while true; do make clean && make -j8 || break; done
Comment 5 commit-hook freebsd_committer 2019-01-04 18:35:36 UTC
A commit references this bug:

Author: emaste
Date: Fri Jan  4 18:35:26 UTC 2019
New revision: 342773
URL: https://svnweb.freebsd.org/changeset/base/342773

Log:
  Add explicit csu test dependency

  lib/csu/tests/dynamiclib requires libh_csu.so be built first.  I'm not
  sure this is the most correct/best way to address this but it solves
  the issue in my testing.

  PR:		233734
  Sponsored by:	The FreeBSD Foundation

Changes:
  head/lib/csu/tests/Makefile
Comment 6 Ed Maste freebsd_committer 2019-01-04 18:37:05 UTC
Bryan would you update lib/csu/tests/Makefile if this should be done differently, or close this PR if this is correct?
Comment 7 Ed Maste freebsd_committer 2019-01-07 14:13:56 UTC
Comparing with other SUBDIR_DEPEND_ use I think this is good.