Skip to content

Commit 9a5e4aa

Browse files
committed
Fix up postboot dependencies [PR106472]
On Wed, Mar 13, 2024 at 10:13:37AM +0100, Jakub Jelinek wrote: > While the first Makefile.tpl hunk looks obviously ok, the others look > completely wrong to me. > There is nothing special about libgo vs. libbacktrace/libatomic > compared to any other target library which is not bootstrapped vs. any > of its dependencies which are in the bootstrapped set. > So, Makefile.tpl shouldn't hardcode such dependencies. Here is my version of the fix. The dependencies in the toplevel Makefile simply didn't take into account that some target modules could be in a bootstrapped build built in some configurations as bootstrap modules (typically as dependencies of other target bootstrap modules), while in other configurations just as dependencies of non-bootstrap target modules and so not built during the bootstrap, but after it. Makefile.tpl arranges for those postboot target module -> target module dependencies to be emitted only inside of an @unless gcc-bootstrap block, while for @if gcc-bootstrap it just emits configure-target-whatever: stage_last dependencies which ensure those postbootstrap target modules are only built after everything that is bootstrapped has been. Now, the libbacktrace/libatomic target modules have bootstrap=true target_modules = { module= libbacktrace; bootstrap=true; }; target_modules = { module= libatomic; bootstrap=true; lib_path=.libs; }; because those modules are dependencies of libphobos target module, so when d is included among bootstrapped languages, those are all bootstrapped and everything works correctly. While if d is not included, libphobos target module is disabled, libbacktrace/libatomic target modules aren't bootstrapped, nothing during bootstrap needs them, but post bootstrap libgo target module depends on the libatomic and libbacktrace target modules, libgfortran target module depends on the libbacktrace target module and libgm2 target module depends on the libatomic target module, but those dependencies were emitted only @unless gcc-bootstrap. There is a similar theoretical problem for zlib target module if GCJ would be ressurected, libphobos as bootstrap target module depends on the zlib target module, but if d is not configured, fastjar also depends on it. The following patch arranges for the @if gcc-bootstrap case to emit also target module -> target module dependencies, but conditionally on the on dependency not being bootstrapped. In the generated Makefile.in you can see what the Makefile.tpl change produces and that it just adds extra dependencies which weren't there before in the @if gcc-bootstrap case. I've bootstrapped without this patch with ../configure --enable-languages=c,c++,go; make on x86_64-linux (note, make -j2 or higher usually worked) which failed as described in the PR, then with this patch with the same command which built fine and the Makefile difference between the two builds being diff -up obj40{a,b}/Makefile --- obj40a/Makefile 2024-03-31 00:35:22.243791499 +0100 +++ obj40b/Makefile 2024-03-31 22:40:38.143299144 +0200 @@ -29376,6 +29376,14 @@ configure-bison: stage_last configure-flex: stage_last configure-m4: stage_last +configure-target-fastjar: maybe-configure-target-zlib +all-target-fastjar: maybe-all-target-zlib +all-target-libgo: maybe-all-target-libbacktrace +all-target-libgo: maybe-all-target-libatomic +all-target-libgm2: maybe-all-target-libatomic +configure-target-libgfortran: maybe-all-target-libbacktrace +configure-target-libgo: maybe-all-target-libbacktrace + # Dependencies for target modules on other target modules are # described by lang_env_dependencies; the defaults apply to anything which I believe are exactly the extra dependencies we want. Plus I've done normal x86_64-linux and i686-linux bootstraps/regtests which in my case include --enable-languages=default,ada,obj-c++,lto,go,d,rust,m2 for x86_64 and the same except ada for i686; those with my usual make -j32. The Makefile difference in those builds vs. unpatched case is just an extra empty line. 2024-04-02 Jakub Jelinek <[email protected]> PR bootstrap/106472 * Makefile.tpl (make-postboot-target-dep): New lambda. Use it to add --enable-bootstrap dependencies of target modules on other target modules if the latter aren't bootstrapped. * Makefile.in: Regenerate.
1 parent 9479205 commit 9a5e4aa

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

Makefile.in

+33
Original file line numberDiff line numberDiff line change
@@ -68677,6 +68677,39 @@ configure-flex: stage_last
6867768677
configure-m4: stage_last
6867868678
@endif gcc-bootstrap
6867968679

68680+
@if gcc-bootstrap
68681+
@unless target-zlib-bootstrap
68682+
configure-target-fastjar: maybe-configure-target-zlib
68683+
@endunless target-zlib-bootstrap
68684+
@unless target-zlib-bootstrap
68685+
all-target-fastjar: maybe-all-target-zlib
68686+
@endunless target-zlib-bootstrap
68687+
@unless target-libstdc++-v3-bootstrap
68688+
configure-target-libgo: maybe-all-target-libstdc++-v3
68689+
@endunless target-libstdc++-v3-bootstrap
68690+
@unless target-libbacktrace-bootstrap
68691+
all-target-libgo: maybe-all-target-libbacktrace
68692+
@endunless target-libbacktrace-bootstrap
68693+
@unless target-libatomic-bootstrap
68694+
all-target-libgo: maybe-all-target-libatomic
68695+
@endunless target-libatomic-bootstrap
68696+
@unless target-libstdc++-v3-bootstrap
68697+
configure-target-libgm2: maybe-all-target-libstdc++-v3
68698+
@endunless target-libstdc++-v3-bootstrap
68699+
@unless target-libatomic-bootstrap
68700+
all-target-libgm2: maybe-all-target-libatomic
68701+
@endunless target-libatomic-bootstrap
68702+
@unless target-libstdc++-v3-bootstrap
68703+
configure-target-libgrust: maybe-all-target-libstdc++-v3
68704+
@endunless target-libstdc++-v3-bootstrap
68705+
@unless target-libbacktrace-bootstrap
68706+
configure-target-libgfortran: maybe-all-target-libbacktrace
68707+
@endunless target-libbacktrace-bootstrap
68708+
@unless target-libbacktrace-bootstrap
68709+
configure-target-libgo: maybe-all-target-libbacktrace
68710+
@endunless target-libbacktrace-bootstrap
68711+
@endif gcc-bootstrap
68712+
6868068713
@unless gcc-bootstrap
6868168714
all-gnattools: maybe-all-target-libstdc++-v3
6868268715
configure-libcc1: maybe-configure-gcc

Makefile.tpl

+24
Original file line numberDiff line numberDiff line change
@@ -2013,6 +2013,25 @@ configure-target-[+module+]: maybe-all-gcc[+
20132013
(unless (=* target "target-")
20142014
(string-append "configure-" target ": " dep "\n"))))))
20152015

2016+
;; Dependencies in between target modules if the dependencies
2017+
;; are bootstrap target modules and the target modules which
2018+
;; depend on them are emitted inside of @unless gcc-bootstrap.
2019+
;; Unfortunately, some target modules like libatomic or libbacktrace
2020+
;; have bootstrap flag set, but whether they are actually built
2021+
;; during bootstrap or after bootstrap depends on e.g. enabled languages;
2022+
;; if d is enabled, libphobos is built as target module and depends
2023+
;; on libatomic and libbacktrace, which are therefore also built as
2024+
;; bootstrap modules. If d is not enabled but go is, libatomic and
2025+
;; libbacktrace are just dependencies of libgo which is not a bootstrap
2026+
;; target module, but we need dependencies on libatomic and libbacktrace
2027+
;; in that case even when gcc-bootstrap. This lambda emits those.
2028+
(define make-postboot-target-dep (lambda ()
2029+
(let ((target (dep-module "module")) (on (dep-module "on")))
2030+
(when (=* on "target-")
2031+
(when (=* target "target-")
2032+
(string-append "@unless " on "-bootstrap\n" (make-dep "" "")
2033+
"\n@endunless " on "-bootstrap\n"))))))
2034+
20162035
;; We now build the hash table that is used by dep-kind.
20172036
(define boot-modules (make-hash-table 113))
20182037
(define postboot-targets (make-hash-table 113))
@@ -2045,6 +2064,11 @@ configure-target-[+module+]: maybe-all-gcc[+
20452064
[+ == "postbootstrap" +][+ (make-postboot-dep) +][+ ESAC +][+
20462065
ENDFOR dependencies +]@endif gcc-bootstrap
20472066

2067+
@if gcc-bootstrap
2068+
[+ FOR dependencies +][+ CASE (dep-kind) +]
2069+
[+ == "postbootstrap" +][+ (make-postboot-target-dep) +][+ ESAC +][+
2070+
ENDFOR dependencies +]@endif gcc-bootstrap
2071+
20482072
@unless gcc-bootstrap
20492073
[+ FOR dependencies +][+ CASE (dep-kind) +]
20502074
[+ == "postbootstrap" +][+ (make-dep "" "") +]

0 commit comments

Comments
 (0)