Skip to content

Commit

Permalink
build: fix probed ar flags usage (re: 57f51b6)
Browse files Browse the repository at this point in the history
That change caused the system to ignore the mamprobe result for
extra flags for ar(1), e.g., AIX needs '-X any'[*]. Restore this
and concentrate the logic in the include file.

[*] https://www.ibm.com/docs/en/aix/7.3?topic=ar-command
  • Loading branch information
McDutchie committed Dec 4, 2024
1 parent e506353 commit 231f059
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
14 changes: 9 additions & 5 deletions src/cmd/INIT/include/link_ar.mam
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@ note *
note * - %{@} - name of archive (like libfoo.a)
note * - %{^} - all the *.o files
note * - %{?} - the *.o files that changed in this run
note *

note * Use path and flags detected by make.probe (e.g. AIX needs '-X any')

setv AR %{mam_cc_AR} %{mam_cc_AR_ARFLAGS}

note * This code avoids rebuilding the archive from scratch on each run,
note * updating only the object files that have changed.

exec - if test -f %{@}
exec - then ar -r -c %{@} %{?} # add changed *.o
exec - else ar -r -c %{@} %{^} # add all *.o
exec - then %{AR} -r -c %{@} %{?} # add changed *.o
exec - else %{AR} -r -c %{@} %{^} # add all *.o
exec - fi || exit

note * Sometimes, obsolete object files can interfere due to intercepts, so
note * delete any old object files that we no longer build from the archive

exec - set +x # avoid noisy log
exec - to_delete=
exec - for o in $(ar -t %{@})
exec - for o in $(%{AR} -t %{@})
exec - do case $o in
exec - *.o) case ' %{^} ' in
exec - *" $o "*)
Expand All @@ -31,6 +35,6 @@ exec - esac
exec - done
exec - case ${to_delete:+y} in
exec - y) set -x
exec - ar -d %{@} $to_delete
exec - %{AR} -d %{@} $to_delete
exec - ;;
exec - esac
1 change: 0 additions & 1 deletion src/cmd/ksh93/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ note *
setv MAMAKE_STRICT 5
setv INSTALLROOT ../../..
setv CC cc
setv AR %{mam_cc_AR} %{mam_cc_AR_ARFLAGS}
setv mam_cc_FLAGS %{mam_cc_TARGET} %{mam_cc_DLL} %{-debug-symbols?1?%{mam_cc_DEBUG} -D_BLD_DEBUG?%{mam_cc_OPTIMIZE}?}
setv CCFLAGS
setv CCLDFLAGS %{-strip-symbols?1?%{mam_cc_LD_STRIP}??}
Expand Down
1 change: 0 additions & 1 deletion src/lib/libast/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ setv INSTALLROOT ../../..
setv PACKAGEROOT ../../../../..
setv INCLUDE_AST %{INSTALLROOT}/include/ast
setv CC cc
setv AR %{mam_cc_AR} %{mam_cc_AR_ARFLAGS}
setv mam_cc_FLAGS %{mam_cc_TARGET} %{mam_cc_DLL} -D_BLD_ast %{-debug-symbols?1?%{mam_cc_DEBUG} -D_BLD_DEBUG?%{mam_cc_OPTIMIZE}?}
setv CCFLAGS
setv CCLDFLAGS %{-strip-symbols?1?%{mam_cc_LD_STRIP}??}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/libcmd/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ note *
setv MAMAKE_STRICT 5
setv INSTALLROOT ../../..
setv CC cc
setv AR %{mam_cc_AR} %{mam_cc_AR_ARFLAGS}
setv mam_cc_FLAGS %{mam_cc_TARGET} %{mam_cc_DLL} %{-debug-symbols?1?%{mam_cc_DEBUG} -D_BLD_DEBUG?%{mam_cc_OPTIMIZE}?} %{mam_cc_NOSTRICTALIASING} -DERROR_CATALOG=\""libcmd"\" -DHOSTTYPE=\""%{mam_cc_HOSTTYPE}"\" -D_BLD_cmd
setv CCFLAGS
setv IFFEFLAGS
Expand Down Expand Up @@ -298,9 +297,10 @@ make install virtual
done
done
make sumlib.o
note * extract sumlib.o from libsum.a
bind -lsum
exec - set -- %{mam_libsum}
exec - %{AR} x "$1" sumlib.o
exec - %{mam_cc_AR} %{mam_cc_AR_ARFLAGS} -x "$1" sumlib.o
done

note * include shell action for linking the library
Expand Down
1 change: 0 additions & 1 deletion src/lib/libdll/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ note *
setv MAMAKE_STRICT 5
setv INSTALLROOT ../../..
setv CC cc
setv AR %{mam_cc_AR} %{mam_cc_AR_ARFLAGS}
setv mam_cc_FLAGS %{mam_cc_TARGET} %{mam_cc_DLL} %{-debug-symbols?1?%{mam_cc_DEBUG} -D_BLD_DEBUG?%{mam_cc_OPTIMIZE}?}
setv CCFLAGS
setv IFFEFLAGS
Expand Down
1 change: 0 additions & 1 deletion src/lib/libsum/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ note *
setv MAMAKE_STRICT 5
setv INSTALLROOT ../../..
setv CC cc
setv AR %{mam_cc_AR} %{mam_cc_AR_ARFLAGS}
setv mam_cc_FLAGS %{mam_cc_TARGET} %{mam_cc_DLL} %{mam_cc_PIC} %{-debug-symbols?1?%{mam_cc_DEBUG} -D_BLD_DEBUG?%{mam_cc_OPTIMIZE}?}
setv CCFLAGS
setv IFFEFLAGS
Expand Down

0 comments on commit 231f059

Please sign in to comment.