Skip to content

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Sep 13, 2020

This PR adds file-based logging for individual packages in depends. To use this feature one should provide LOG=1.

A log file is printed out automatically in case of a build error. After successful build log files are being moved along with package archives:

$ make -C depends HOST=x86_64-w64-mingw32 LOG=1
$ find ./depends/built/x86_64-w64-mingw32 -name '*.log' | sort
./depends/built/x86_64-w64-mingw32/bdb/bdb-4.8.30-5100a099801.log
./depends/built/x86_64-w64-mingw32/boost/boost-1_71_0-313f82dc7de.log
./depends/built/x86_64-w64-mingw32/libevent/libevent-2.1.12-stable-3fa27048d5e.log
./depends/built/x86_64-w64-mingw32/libnatpmp/libnatpmp-4536032ae32268a45c073a4d5e91bbab4534773a-9db4850dd32.log
./depends/built/x86_64-w64-mingw32/miniupnpc/miniupnpc-2.2.2-75d9a1807e0.log
./depends/built/x86_64-w64-mingw32/native_b2/native_b2-1_71_0-3bf253c19bf.log
./depends/built/x86_64-w64-mingw32/qrencode/qrencode-3.4.4-dfac87af599.log
./depends/built/x86_64-w64-mingw32/qt/qt-5.15.2-9304e03d3ac.log
./depends/built/x86_64-w64-mingw32/sqlite/sqlite-3320100-455acafa7be.log
./depends/built/x86_64-w64-mingw32/zeromq/zeromq-4.3.1-5ff627ec84a.log

An example of CI tasks with package build errors -- https://cirrus-ci.com/task/5275741788045312

Closes #16368.

@practicalswift
Copy link
Contributor

Concept ACK

@hebasto
Copy link
Member Author

hebasto commented Sep 13, 2020

cc @dongcarl

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 19, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #24285 (build, refactor: Drop useless call Make function by hebasto)
  • #24279 (build: Make $(package)_*_env available to all $(package)_*_cmds by hebasto)
  • #23611 (build: add LTO option to depends (no Qt) by fanquake)
  • #23571 (build: Propagate user-defined tools to native packages by hebasto)
  • #22811 (build: Fix depends build system when working with subtargets by hebasto)
  • #22126 (build: Disable make builtin rules. by dgoncharov)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@maflcko
Copy link
Member

maflcko commented Oct 2, 2020

Concept ACK. Does the ci print the log on failure?

@hebasto
Copy link
Member Author

hebasto commented Oct 2, 2020

Updated 95b5dfa -> 68459dd (pr19952.01 -> pr19952.02):

Concept ACK. Does the ci print the log on failure?

An example of failure logging in CI -- https://travis-ci.org/github/hebasto/bitcoin/builds/732364252 with the following patch:

--- a/depends/patches/qt/freetype_back_compat.patch
+++ b/depends/patches/qt/freetype_back_compat.patch
@@ -22,7 +22,7 @@ index 3f543755..8ecc1c8c 100644
      }
  #if defined(FT_FONT_FORMATS_H)
 -    const char *fmt = FT_Get_Font_Format(face);
-+    const char *fmt = FT_Get_X11_Font_Format(face);
++    const char *fmt = FT_Get_X11_Font_Format(face)
      if (fmt && qstrncmp(fmt, "CFF", 4) == 0) {
          FT_Bool no_stem_darkening = true;
          FT_Error err = FT_Property_Get(qt_getFreetype(), "cff", "no-stem-darkening", &no_stem_darkening);

@hebasto
Copy link
Member Author

hebasto commented Nov 8, 2020

Rebased 68459dd -> 4b676b1 (pr19952.02 -> pr19952.03).

@@ -121,6 +121,8 @@ build script logic) are searched for among the host system packages using
<dd>(EXPERTS ONLY) When cross-compiling for macOS, use Clang found in the
system's <code>$PATH</code> rather than the default prebuilt release of Clang
from llvm.org. Clang 8 or later is required.</dd>
<dt>LOG</dt>
<dd>Use file-based logging for individual packages</dd>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add more details? For example, where would we expect these log files to appear?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If wording in the updated OP is ok, I'll push it into the docs.

@laanwj
Copy link
Member

laanwj commented Nov 20, 2020

Concept ACK, I think not being verbose unless the level of detail is really needed (say, on a failure) is good for build/test commands. Makes it easier to spot actual problems.
Please do make it easy to figure out where the logs went in case they're needed though 🙂

@hebasto
Copy link
Member Author

hebasto commented Dec 19, 2020

Updated 4b676b1 -> 46e2ff7 (pr19952.03 -> pr19952.04):

  • rebased on top of the recent CI changes
  • addressed @laanwj's comment:

Please do make it easy to figure out where the logs went in case they're needed though

The example of CI output in case of error during depends build is here.

@dongcarl
Copy link
Contributor

Hmmm, I've been thinking about this... And wondering if we could use tee and process substitute to do:

diff --git a/depends/funcs.mk b/depends/funcs.mk
index 3ddeaf0378..2de5f67b5c 100644
--- a/depends/funcs.mk
+++ b/depends/funcs.mk
@@ -80,7 +80,7 @@ $(1)_download_path_fixed=$(subst :,\:,$$($(1)_download_path))
 # The default behavior for tar will try to set ownership when running as uid 0 and may not succeed, --no-same-owner disables this behavior
 $(1)_fetch_cmds ?= $(call fetch_file,$(1),$(subst \:,:,$$($(1)_download_path_fixed)),$$($(1)_download_file),$($(1)_file_name),$($(1)_sha256_hash))
 $(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash)  $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash &&  $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && tar --no-same-owner --strip-components=1 -xf $$($(1)_source)
-$(1)_preprocess_cmds ?= true
+$(1)_preprocess_cmds ?=
 $(1)_build_cmds ?=
 $(1)_config_cmds ?=
 $(1)_stage_cmds ?=
@@ -177,7 +177,7 @@ endef
 
 define int_add_cmds
 ifneq ($(LOG),)
-$(1)_logging = >>$$($(1)_build_log) 2>&1 || { if test -f $$($(1)_build_log); then cat $$($(1)_build_log); fi; exit 1; }
+$(1)_logging = exec >> >(tee -a $$($(1)_build_log)) 2>&1;
 endif
 
 $($(1)_fetched):
@@ -196,23 +196,23 @@ $($(1)_preprocessed): | $($(1)_extracted)
 	$(AT)echo Preprocessing $(1)...
 	$(AT)mkdir -p $$(@D) $($(1)_patch_dir)
 	$(AT)$(foreach patch,$($(1)_patches),cd $(PATCHES_PATH)/$(1); cp $(patch) $($(1)_patch_dir) ;)
-	$(AT){ cd $$(@D); $(call $(1)_preprocess_cmds, $(1)); } $$($(1)_logging)
+	$(AT)( $$($(1)_logging) cd $$(@D); $(call $(1)_preprocess_cmds, $(1)) )
 	$(AT)touch $$@
 $($(1)_configured): | $($(1)_dependencies) $($(1)_preprocessed)
 	$(AT)echo Configuring $(1)...
 	$(AT)rm -rf $(host_prefix); mkdir -p $(host_prefix)/lib; cd $(host_prefix); $(foreach package,$($(1)_all_dependencies), tar --no-same-owner -xf $($(package)_cached); )
 	$(AT)mkdir -p $$(@D)
-	$(AT)+{ cd $$(@D); $($(1)_config_env) $(call $(1)_config_cmds, $(1)); } $$($(1)_logging)
+	$(AT)+( $$($(1)_logging) cd $$(@D); $($(1)_config_env) $(call $(1)_config_cmds, $(1)) )
 	$(AT)touch $$@
 $($(1)_built): | $($(1)_configured)
 	$(AT)echo Building $(1)...
 	$(AT)mkdir -p $$(@D)
-	$(AT)+{ cd $$(@D); $($(1)_build_env) $(call $(1)_build_cmds, $(1)); } $$($(1)_logging)
+	$(AT)+( $$($(1)_logging) cd $$(@D); $($(1)_build_env) $(call $(1)_build_cmds, $(1)) )
 	$(AT)touch $$@
 $($(1)_staged): | $($(1)_built)
 	$(AT)echo Staging $(1)...
 	$(AT)mkdir -p $($(1)_staging_dir)/$(host_prefix)
-	$(AT)+{ cd $($(1)_build_dir); $($(1)_stage_env) $(call $(1)_stage_cmds, $(1)); } $$($(1)_logging)
+	$(AT)+( $$($(1)_logging) cd $($(1)_build_dir); $($(1)_stage_env) $(call $(1)_stage_cmds, $(1)) )
 	$(AT)rm -rf $($(1)_extract_dir)
 	$(AT)touch $$@
 $($(1)_postprocessed): | $($(1)_staged)

I supposed POSIX sh doesn't have process substitution... But perhaps for depends we can set .SHELL = bash? Just thinking...

@hebasto
Copy link
Member Author

hebasto commented Jan 3, 2022

@dongcarl

I supposed POSIX sh doesn't have process substitution... But perhaps for depends we can set .SHELL = bash? Just thinking...

Right. It does not work in sh or dash scripts. But we should support dash.

@hebasto
Copy link
Member Author

hebasto commented Jan 3, 2022

Updated 46e2ff7 -> bdd1056 (pr19952.04 -> pr19952.05) due to the conflict with #22283.

@hebasto
Copy link
Member Author

hebasto commented Feb 2, 2022

Rebased bdd1056 -> 0b9357b (pr19952.05 -> pr19952.06) due to the conflict with #24212.

@hebasto
Copy link
Member Author

hebasto commented Feb 13, 2022

Rebased 0b9357b -> 3c5c583 (pr19952.06 -> pr19952.07) due to the conflict with #23998.

@hebasto
Copy link
Member Author

hebasto commented Feb 13, 2022

Guix builds:

$ find guix-build-$(git rev-parse --short=12 HEAD)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
e0e8d12c43c077aa59be7ef51d0290c1c0a204592b03a024d7e98054547b4298  guix-build-3c5c5839fe61/output/aarch64-linux-gnu/SHA256SUMS.part
2b04b0c30974d5ec8bb048890a4c89e31afb60b7e638155b73c96a0cb07603a6  guix-build-3c5c5839fe61/output/aarch64-linux-gnu/bitcoin-3c5c5839fe61-aarch64-linux-gnu-debug.tar.gz
cd8be3cdd7a54877dce307072b646e3706b57f626e2ea13f38274394aa9ae16f  guix-build-3c5c5839fe61/output/aarch64-linux-gnu/bitcoin-3c5c5839fe61-aarch64-linux-gnu.tar.gz
9a760fb5b0b1f7a7c1d35cac6b4447eea77823722230d3bf19d8a809ac7affdc  guix-build-3c5c5839fe61/output/arm-linux-gnueabihf/SHA256SUMS.part
fc53bb9ec64fa928baf787119174ba2dc8a48f982eec85554073a04cf5a8416f  guix-build-3c5c5839fe61/output/arm-linux-gnueabihf/bitcoin-3c5c5839fe61-arm-linux-gnueabihf-debug.tar.gz
c7720367ef22d2f2f622cfdee492d7101eae3633c7b61ee9035837bd267438c0  guix-build-3c5c5839fe61/output/arm-linux-gnueabihf/bitcoin-3c5c5839fe61-arm-linux-gnueabihf.tar.gz
e064e261db13ebeafcb9bcc1ca8b1fca16d8105a9e4454b6f240cd055236789b  guix-build-3c5c5839fe61/output/arm64-apple-darwin/SHA256SUMS.part
3bb7a65fb83ebf0b2d06c2d1d1e9bee096198a0c7f9f7b8c41e0f7d9a4f85650  guix-build-3c5c5839fe61/output/arm64-apple-darwin/bitcoin-3c5c5839fe61-arm64-apple-darwin.tar.gz
39b9d88cb56e9a2e5626c7673f6bcc2764ac341a9bd9d4cf048900543261013c  guix-build-3c5c5839fe61/output/arm64-apple-darwin/bitcoin-3c5c5839fe61-osx-unsigned.dmg
8d5b5acd83883c53228527ca87be6af46c765243d8bdab073ec2355c110394dd  guix-build-3c5c5839fe61/output/arm64-apple-darwin/bitcoin-3c5c5839fe61-osx-unsigned.tar.gz
2f605b0320c90cd30028724d3684971c0b323135d5bdc3894e826b54aab5a79d  guix-build-3c5c5839fe61/output/dist-archive/bitcoin-3c5c5839fe61.tar.gz
e4d5faaa07788ed1b454ecbbcdc81d1546239a8356fa3c118dc4d4714ad2e771  guix-build-3c5c5839fe61/output/powerpc64-linux-gnu/SHA256SUMS.part
3a2401d8b989b7f9a714f27d4c8894040d5407e0d4d841adc705ff420a119467  guix-build-3c5c5839fe61/output/powerpc64-linux-gnu/bitcoin-3c5c5839fe61-powerpc64-linux-gnu-debug.tar.gz
f86901a9f2336201f5a3cac2556ad317e0ef33a1a89303557ee0ceb5ee31c43d  guix-build-3c5c5839fe61/output/powerpc64-linux-gnu/bitcoin-3c5c5839fe61-powerpc64-linux-gnu.tar.gz
b7302a12063fc85a96077f9048451d737ae3a5f950ad17fc521a63d02063b6b7  guix-build-3c5c5839fe61/output/powerpc64le-linux-gnu/SHA256SUMS.part
d181f8ee35239094d3dfa953bd8ba3d51a8ee38a4038149a15f400d386587274  guix-build-3c5c5839fe61/output/powerpc64le-linux-gnu/bitcoin-3c5c5839fe61-powerpc64le-linux-gnu-debug.tar.gz
810d60570ca083217fc2eb378bceb5361605dda47ae2fd76bc693a027ee8409a  guix-build-3c5c5839fe61/output/powerpc64le-linux-gnu/bitcoin-3c5c5839fe61-powerpc64le-linux-gnu.tar.gz
b2f8d87ae3d8ce4abb121b7f589f9d1db71ee32a456fec3639e7714d0fa7ca5f  guix-build-3c5c5839fe61/output/riscv64-linux-gnu/SHA256SUMS.part
994d00a6514c704ac177f48790b9acb586f1e56f8aa702b205d532d95a81e2d9  guix-build-3c5c5839fe61/output/riscv64-linux-gnu/bitcoin-3c5c5839fe61-riscv64-linux-gnu-debug.tar.gz
b4bacd388be1f687404baa31650647e3416b743d0a8ceb4a57121d25750cb0fc  guix-build-3c5c5839fe61/output/riscv64-linux-gnu/bitcoin-3c5c5839fe61-riscv64-linux-gnu.tar.gz
f285e4da8535f25605f3f16e3f72b8a8f64210ec4686b5aba784ff48842476d9  guix-build-3c5c5839fe61/output/x86_64-apple-darwin/SHA256SUMS.part
af453058f80b0a933563ab5c3f8003af75e37d79fff823f418ba881c9e53ed81  guix-build-3c5c5839fe61/output/x86_64-apple-darwin/bitcoin-3c5c5839fe61-osx-unsigned.dmg
7eb22cd46617f0c1a55328931e3fa5e7a9bb481ff56dc136fe62854ef08dde99  guix-build-3c5c5839fe61/output/x86_64-apple-darwin/bitcoin-3c5c5839fe61-osx-unsigned.tar.gz
3456ac4af66f2e71473a3d891c9e953a39a49cbd306d8d9d935e50aa50dea8d8  guix-build-3c5c5839fe61/output/x86_64-apple-darwin/bitcoin-3c5c5839fe61-osx64.tar.gz
d35fde85151a30f780bf69c12e40399ac96810e1cb6dfa7861fb7a48d0be801d  guix-build-3c5c5839fe61/output/x86_64-linux-gnu/SHA256SUMS.part
b1994d47c85bfa248b0483bc910d805718c2c920571e9e465d5cbe6da3cae65b  guix-build-3c5c5839fe61/output/x86_64-linux-gnu/bitcoin-3c5c5839fe61-x86_64-linux-gnu-debug.tar.gz
591e0d6d7a706d10b5bcbe93387560b6790dd989f046d0a32ec20e028bbda037  guix-build-3c5c5839fe61/output/x86_64-linux-gnu/bitcoin-3c5c5839fe61-x86_64-linux-gnu.tar.gz

@hebasto hebasto force-pushed the 200913-log branch 2 times, most recently from e87f5fc to eb4b01e Compare April 5, 2022 18:02
@hebasto
Copy link
Member Author

hebasto commented Apr 5, 2022

Rebased 3c5c583 -> eb4b01e (pr19952.07 -> pr19952.08) due to the conflict with #24522.

@hebasto
Copy link
Member Author

hebasto commented Apr 5, 2022

Friendly ping @dongcarl @MarcoFalke

@maflcko
Copy link
Member

maflcko commented Apr 5, 2022

Concept ACK

@hebasto
Copy link
Member Author

hebasto commented Apr 14, 2022

Rebased eb4b01e -> 86c2889 (pr19952.08 -> pr19952.09) due to the conflict with #24285.

@laanwj
Copy link
Member

laanwj commented Apr 14, 2022

Going to test this.

@laanwj
Copy link
Member

laanwj commented Apr 14, 2022

Tested ACK 86c2889

I know it's not the intended use but I patched this into the guix build, as that's the only depends build i do at the moment:

--- a/contrib/guix/libexec/build.sh
+++ b/contrib/guix/libexec/build.sh
@@ -198,7 +198,7 @@ esac
 ####################
 
 # Build the depends tree, overriding variables that assume multilib gcc
-make -C depends --jobs="$JOBS" HOST="$HOST" \
+make -C depends --jobs="$JOBS" HOST="$HOST" LOG=1 \
                                    ${V:+V=1} \
                                    ${SOURCES_PATH+SOURCES_PATH="$SOURCES_PATH"} \
                                    ${BASE_CACHE+BASE_CACHE="$BASE_CACHE"} \

The log was clean. A lot less spammy, this is good!:

make: Entering directory '/bitcoin/depends'
Extracting boost...
/home/guest/sources/boost_1_77_0.tar.bz2: OK
Preprocessing boost...
Configuring boost...
Building boost...
Staging boost...
Postprocessing boost...
Caching boost...
Extracting libevent...
/home/guest/sources/libevent-2.1.12-stable.tar.gz: OK
Preprocessing libevent...
Configuring libevent...
⋮ 
Preprocessing zeromq...
Configuring zeromq...
Building zeromq...
Staging zeromq...
Postprocessing zeromq...
Caching zeromq...
copying packages: boost libevent qt expat libxcb xcb_proto libXau xproto freetype fontconfig libxkbcommon libxcb_util libxcb_util_render libxcb_util_keysyms libxcb_util_image libxcb_util_wm qrencode bdb sqlite miniupnpc libnatpmp systemtap zeromq
to: /bitcoin/depends/riscv64-linux-gnu

After the build, the individual log files could be found in the cache:

./base-cache/riscv64-linux-gnu/qt/qt-5.15.3-30a361c8788.log
./base-cache/riscv64-linux-gnu/libnatpmp/libnatpmp-4536032ae32268a45c073a4d5e91bbab4534773a-59aa9cc4671.log
./base-cache/riscv64-linux-gnu/qrencode/qrencode-3.4.4-0469a7d34c9.log
./base-cache/riscv64-linux-gnu/boost/boost-1.77.0-1f1d64dbf3c.log
./base-cache/riscv64-linux-gnu/libxcb_util_render/libxcb_util_render-0.3.9-95703f260b3.log
⋮ 
./base-cache/riscv64-linux-gnu/bdb/bdb-4.8.30-cf38a657499.log
./base-cache/riscv64-linux-gnu/sqlite/sqlite-3320100-06ea4df8e5e.log
./base-cache/riscv64-linux-gnu/libxcb_util_keysyms/libxcb_util_keysyms-0.4.0-baf1d726a20.log
./base-cache/riscv64-linux-gnu/fontconfig/fontconfig-2.12.6-181950ffe12.log
./base-cache/riscv64-linux-gnu/expat/expat-2.4.1-24df0173864.log

I also corrupted a patch intentionally to see if the logging would still report the error in that case, it does:

make: Entering directory '/bitcoin/depends'
Extracting qt...
/home/guest/sources/qtbase-everywhere-opensource-src-5.15.3.tar.xz: OK
/home/guest/sources/qttranslations-everywhere-opensource-src-5.15.3.tar.xz: OK
/home/guest/sources/qttools-everywhere-opensource-src-5.15.3.tar.xz: OK
Preprocessing qt...
patching file qtbase/configure
patch: **** malformed patch at line 19: dsoiusaoifasdfiadfiosudfsduf

make: *** [funcs.mk:289: /bitcoin/depends/work/build/riscv64-linux-gnu/qt/5.15.3-3a31e8c8789/.stamp_preprocessed] Error 1
make: Leaving directory '/bitcoin/depends'

@laanwj laanwj merged commit e14f0fa into bitcoin:master Apr 14, 2022
@hebasto hebasto deleted the 200913-log branch April 14, 2022 19:33
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 14, 2022
… packages

86c2889 ci: Make log verbose in error case only (Hennadii Stepanov)
7f65088 depends: Add file-based logging for individual packages (Hennadii Stepanov)

Pull request description:

  This PR adds file-based logging for individual packages in depends. To use this feature one should provide `LOG=1`.

  A log file is printed out automatically in case of a build error. After successful build log files are being moved along with package archives:
  ```
  $ make -C depends HOST=x86_64-w64-mingw32 LOG=1
  $ find ./depends/built/x86_64-w64-mingw32 -name '*.log' | sort
  ./depends/built/x86_64-w64-mingw32/bdb/bdb-4.8.30-5100a099801.log
  ./depends/built/x86_64-w64-mingw32/boost/boost-1_71_0-313f82dc7de.log
  ./depends/built/x86_64-w64-mingw32/libevent/libevent-2.1.12-stable-3fa27048d5e.log
  ./depends/built/x86_64-w64-mingw32/libnatpmp/libnatpmp-4536032ae32268a45c073a4d5e91bbab4534773a-9db4850dd32.log
  ./depends/built/x86_64-w64-mingw32/miniupnpc/miniupnpc-2.2.2-75d9a1807e0.log
  ./depends/built/x86_64-w64-mingw32/native_b2/native_b2-1_71_0-3bf253c19bf.log
  ./depends/built/x86_64-w64-mingw32/qrencode/qrencode-3.4.4-dfac87af599.log
  ./depends/built/x86_64-w64-mingw32/qt/qt-5.15.2-9304e03d3ac.log
  ./depends/built/x86_64-w64-mingw32/sqlite/sqlite-3320100-455acafa7be.log
  ./depends/built/x86_64-w64-mingw32/zeromq/zeromq-4.3.1-5ff627ec84a.log
  ```

  An example of CI tasks with package build errors -- https://cirrus-ci.com/task/5275741788045312

  Closes bitcoin#16368.

ACKs for top commit:
  laanwj:
    Tested ACK 86c2889

Tree-SHA512: 497f2146fd2e38c952124aecfd80ebb42be22bbc5dc59521491545f4465fc38f23da7787a0caea5686b7c30aa862f2b0c02092ae3fe863e80a5ddd14b3d324b9
@bitcoin bitcoin locked and limited conversation to collaborators Jul 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

depends: File-based logging for individual packages
7 participants