Bug 233734 - Possible build race: ld: cannot find -lh_csu
Summary: Possible build race: ld: cannot find -lh_csu
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Ed Maste
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-02 21:20 UTC by Li-Wen Hsu
Modified: 2019-09-16 13:42 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Li-Wen Hsu freebsd_committer freebsd_triage 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 freebsd_triage 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 freebsd_triage 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 freebsd_triage 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 freebsd_triage 2019-01-07 14:13:56 UTC
Comparing with other SUBDIR_DEPEND_ use I think this is good.
Comment 8 commit-hook freebsd_committer freebsd_triage 2019-09-16 13:42:02 UTC
A commit references this bug:

Author: andrew
Date: Mon Sep 16 13:41:30 UTC 2019
New revision: 352394
URL: https://svnweb.freebsd.org/changeset/base/352394

Log:
  MFC r339738, r339744, r339770, r339773, r339864-r339866, r339907-r339908, r339912-r339913, r339916, r339954, r340213, r340395, r340840, r340910-r340911, r341424, r342773, r342974, r351027, r352073:

  MFC the BSD crtbegin to stable/12 but keep it disabled.

  r339738:
  Implement a BSD licensed crtbegin/crtend

  These are needed for .ctors/.dtors and .jcr handling. The former needs
  all the function pointers to be called in the correct order from the
  .init/.fini section. The latter just needs to call a gcj specific function
  if it exists with a pointer to the start of the .jcr section.

  This is currently disabled until __dso_handle support is added.

  Reviewed by:	emaste
  Sponsored by:	DARPA, AFRL
  Differential Revision:	https://reviews.freebsd.org/D17587

  r339744:
  Add a missing include for src.opts.mk. Without it MK_TESTS isn't defined.

  MFC with:	r339738
  Sponsored by:	DARPA, AFRL

  r339770:
  Drop the csu tests WARNS to 5 to fix the powerpc64 build.

  MFC with:	r339738
  Sponsored by:	DARPA, AFRL

  r339773:
  Add __dso_handle to the BSD crtbegin. This is used to identify shared
  objects.

  MFC with:	r339738
  Sponsored by:	DARPA, AFRL

  r339864:
  Check __dso_handle is NULL in non-DSO objects. It should only be non-NULL
  when accessed from a shared object.

  MFC with:	r339738
  Sponsored by:	DARPA, AFRL

  r339865:
  Include the csu test directories in BSD.tests.dist

  MFC with:	r339738
  Sponsored by:	DARPA, AFRL

  r339866:
  Make the .ctors, .dtors, and .jcr markers as static. They shouldn't be
  accessible from out of the files they are defined in.

  MFC with:	r339738
  Sponsored by:	DARPA, AFRL

  r339907:
  The jcr argument to _Jv_RegisterClasses is used, stop marking it otherwise.

  MFC with:	r339738
  Sponsored by:	DARPA, AFRL

  r339908:
  Run the csu tests on a DSO. This builds the tests into a shared library,
  then runs these from the base test programs. With this we can check
  crtbeginS.o and crtendS.o are working as expected.

  MFC with:	r339738
  Sponsored by:	DARPA, AFRL

  r339912:
  Fix the location of the static keyword.

  MFC with:	r339738
  Sponsored by:	DARPA, AFRL

  r339913:
  Disable the .preinit_array test in DSOs, ld.bfd fails to link objects with
  the section.

  MFC with:	r339738
  Sponsored by:	DARPA, AFRL

  r339916:
  Build the csu tests on all architectures.

  The tests haven't been run them, but this is enough to build them so I can
  get feedback on if the various crt.h headers are correct.

  MFC with:	r339738
  Sponsored by:	DARPA, AFRL

  r339954:
  Add __used to __CTOR_LIST__ and __DTOR_LIST__

  Enabling BSD_CRTBEGIN on amd64 resulted in
  error: unused variable '__CTOR_LIST__'.

  __CTOR_LIST__ is indeed unused in crtbegin.c; it marks the beginning of
  the .ctors array and is used in crtend.c.  Annotate __DTOR_LIST__ as
  well for consistency.

  Discussed with:	andrew
  MFC with:	r339738
  Sponsored by:	The FreeBSD Foundation

  r340213:
  Add the (untested) mips and sparc64 .init call sequences.

  The BSD crtbegin/crtend code now builds on all architectures, however
  further work is needed to check if it works correctly.

  MFC with:	r339738
  Sponsored by:	DARPA, AFRL

  r340395:
  Run __cxa_finalize in shared objects in the destructor path.

  When we have .dtors call them before .dtor handling, otherwise call from
  a destructor.

  PR:		233056
  MFC with:	r339738
  Sponsored by:	DARPA, AFRL

  r340840:
  Mark the function called by the MIPS .init/.fini sequence with .local.

  As with r328939 we need to mark local symbols as such. Without this the
  assembly parser treats the symbols as global and created relocations
  against these private symbols.

  MFC with:	r339738
  Sponsored by:	DARPA, AFRL

  r340910:
  Add the missing 0 at the end of the .jcr section.

  Without this the dynamic library test was failing as it was calling
  _Jv_RegisterClasses multiple times.

  r340911:
  Re-enable the dynamiclib tests. These should be fixed by r340910.

  r341424:
  Disable the BSD CRT code on powerpc and sparc64, they need extra crt*.o
  files that haven't been implemented.

  Reported by:	sbruno
  MFC with:	r339738
  Sponsored by:	DARPA, AFRL

  r342773:
  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

  r342974:
  Create crtsavres.o for powerpc builds

  Summary:
  GCC expects to link in a crtsavres.o on powerpc platforms.  On
  powerpc64 this is an empty file, but on powerpc and powerpcspe this does contain
  some save/restore functions, which may not actually be necessary for newer
  modern GCC and clang.  This appeases the in-tree gcc, though, and is needed in
  order to switch to the BSD CRTRBEGIN.

  PR:	233751
  Reviewed By: andrew
  Differential Revision: https://reviews.freebsd.org/D18826

  r351027:
  Enable BSD_CRTBEGIN on powerpc

  In r342974 jhibbits added support to build crtsavres.o. This was the
  blocker for BSD_CRTBEGIN to be enabled there. As such enable this
  option again.

  Reviewed by:	jhibbits
  Sponsored by:	DARPA, AFRL

  r352073:
  csu: Add the riscv .init call sequence

  Reviewed by:	br
  Sponsored by:	Axiado
  Differential Revision:	https://reviews.freebsd.org/D21537

Changes:
_U  stable/12/
  stable/12/etc/mtree/BSD.tests.dist
  stable/12/gnu/lib/Makefile
  stable/12/gnu/lib/csu/Makefile
  stable/12/lib/csu/Makefile
  stable/12/lib/csu/Makefile.inc
  stable/12/lib/csu/aarch64/crt.h
  stable/12/lib/csu/amd64/crt.h
  stable/12/lib/csu/arm/crt.h
  stable/12/lib/csu/common/crtbegin.c
  stable/12/lib/csu/common/crtend.c
  stable/12/lib/csu/i386/crt.h
  stable/12/lib/csu/mips/crt.h
  stable/12/lib/csu/powerpc/Makefile
  stable/12/lib/csu/powerpc/crt.h
  stable/12/lib/csu/powerpc/crtsavres.S
  stable/12/lib/csu/powerpc64/Makefile
  stable/12/lib/csu/powerpc64/crt.h
  stable/12/lib/csu/riscv/crt.h
  stable/12/lib/csu/sparc64/crt.h
  stable/12/lib/csu/tests/
  stable/12/lib/csu/tests/Makefile
  stable/12/lib/csu/tests/Makefile.tests
  stable/12/lib/csu/tests/cxx_constructors.cc
  stable/12/lib/csu/tests/dso/
  stable/12/lib/csu/tests/dynamic/Makefile
  stable/12/lib/csu/tests/dynamiclib/
  stable/12/lib/csu/tests/fini_test.c
  stable/12/lib/csu/tests/init_test.c
  stable/12/lib/csu/tests/static/Makefile
  stable/12/share/mk/src.opts.mk
  stable/12/tools/build/options/WITHOUT_BSD_CRTBEGIN
  stable/12/tools/build/options/WITH_BSD_CRTBEGIN