Skip to content

parallel build: First set of fixes - #4854

Merged
th0ma7 merged 18 commits into
SynoCommunity:masterfrom
th0ma7:makeflags
Sep 13, 2021
Merged

th0ma7 merged 18 commits into
SynoCommunity:masterfrom
th0ma7:makeflags

Conversation

@th0ma7

@th0ma7 th0ma7 commented Sep 11, 2021 •

Copy link
Copy Markdown
Contributor

Motivation: Follow-up on parallel-build issues...

  • Fix logging to PSTAT at all MAKELEVEL
  • PSTAT logging more specific with added [BEGIN] and [END] messages
  • Re-uses @publicarray fix for cmake
  • Move back to using cmake by default
  • Move libaom only to using ninja by default
  • When building multiple specific archs, force building native in sequence first (e.g. pre-build-native)
  • Make all possible cross/* to use default COMPILE_TARGET to allow parallel build (bzip2, dropbear, lua, mpfr, mtproxy, node-exporter, p7zip, python3, python38, rtorrent, tcp_wrappers, udns, unzip)

Linked issues: This should fix issue found in #4683

Checklist

  • Build rule all-supported completed successfully
  • Package upgrade completed successfully
  • New installation of package completed successfully

@th0ma7 th0ma7 mentioned this pull request Sep 11, 2021
3 tasks
@th0ma7
th0ma7 requested review from hgy59 and publicarray September 11, 2021 13:02
Comment thread spk/ffmpeg/Makefile Resolved
@th0ma7 th0ma7 mentioned this pull request Sep 12, 2021
6 tasks done
When invoking make -j2 arch-armada38x it tries to build
both arch-arch-armada38x-6.1 and arch-arch-armada38x-7.0.
This fails when hitting native/* dependencies as they must
be built in sequence first, and only then switch to parallel
for all arch-* requested.

This issue was faced originally with make all-supported and
fixed by calling first pre-build-native as needed.  The change
here addresses this to allow the same building process when
multiple arch-* are passed by the user.
Comment thread cross/busybox/Makefile Resolved
@th0ma7 th0ma7 self-assigned this Sep 12, 2021
@th0ma7

th0ma7 commented Sep 12, 2021

Copy link
Copy Markdown
Contributor Author

I think I've shaken out all the remaining bugs. Most of them occurred on a "virgin" tree wheras on an existing tree with pre-compile native and pre-downloaded distrib & toolchain it would not show.

@publicarray if you have a few spare cycles can you give it a shot with variations such as from cross and spk :

$ make all-supported
$ make -jX all-supported
$ PARALLEL_MAKE make all-supported
$ PARALLEL_MAKE make -jX all-supported
--
$ make arch-apollolake
$ make -jX arch-apollolake
$ PARALLEL_MAKE make arch-apollolake
$ PARALLEL_MAKE make -jX arch-apollolake
--
$ make arch-apollolake-7.0
$ make -jX arch-apollolake-7.0
$ PARALLEL_MAKE make arch-apollolake-7.0
$ PARALLEL_MAKE make -jX arch-apollolake-7.0
--
$ make arch-apollolake-7.0 arch-apollolake-6.1
$ make -jX arch-apollolake-7.0 arch-apollolake-6.1
$ PARALLEL_MAKE make arch-apollolake-7.0 arch-apollolake-6.1
$ PARALLEL_MAKE make -jX arch-apollolake-7.0 arch-apollolake-6.1

And perhaps also simply directly make under toolchain or native...

@fgma

fgma commented Sep 12, 2021

Copy link
Copy Markdown
Contributor

@th0ma7 I've checked out this branch. Compiling minio for 6.1 works. 7.0 obviously fails which is expected because this is still the old version.

The problem I found was easily reproducible in spksrc's master branch and is completely unrelated to my PR #4683.

@th0ma7

th0ma7 commented Sep 12, 2021

Copy link
Copy Markdown
Contributor Author

@th0ma7 I've checked out this branch. Compiling minio for 6.1 works. 7.0 obviously fails which is expected because this is still the old version.

The problem I found was easily reproducible in spksrc's master branch and is completely unrelated to my PR #4683.

I was also able to build your branch by copying over all the mk/* files from this PR. Things seems to be looking good, thnx. I'll wait for a review to confirm all is still ok before merging.

Many cross dependencies had uncessary COMPILE_TARGET that can be
remove by using COMPILE_MAKE_OPTIONS.  This has the benefit of
call default compile target and thus using PARALLEL_MAKE flag
to benefit from all CPU when compiling.
Aloow passing MAKEFLAGS to native compile which enable parallel
building of all native dependencies, thus reducing compile time
significantly.
@th0ma7

th0ma7 commented Sep 12, 2021 •

Copy link
Copy Markdown
Contributor Author

@hgy59 and @publicarray I was able to make all possible cross/* to use default COMPILE_TARGET to allow parallel build (bzip2, dropbear, lua, mpfr, mtproxy, node-exporter, p7zip, python3, python38, rtorrent, tcp_wrappers, udns, unzip).

I've applied to same to the native/* (only had a handful). I do not see anything else for now that I could make parallel further...

BTW, python is now much faster to compile, that's including the native build ... :)

$ time make arch-apollolake-7.0
real	8m39.877s
user	18m47.822s
sys	3m39.674s

$ time make arch-apollolake-6.1
real	8m24.407s
user	17m48.153s
sys	3m9.713s

Comment thread cross/unzip/Makefile
@@ -12,16 +12,16 @@ COMMENT = UnZip is an extraction utility for archives compressed in .zip format
LICENSE = http://infozip.sourceforge.net/license.html

GNU_CONFIGURE = 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

GNU_CONFIGURE = 1 is obsolete with CONFIGURE_TARGET = nop

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I can indeed remove the GNU_CONFIGURE. Want me to fix the other ones while at it?

spksrc@spksrc-debian10:~/makeflags/spksrc$ grep GNU_CONFIGURE */*/Makefile | grep 1 | while read LINE; do FILE=$(echo $LINE | cut -f1 -d:); grep -q "CONFIGURE_TARGET = nop" $FILE && echo $FILE; done
cross/libcap/Makefile
cross/p7zip/Makefile
cross/ps3netsrv/Makefile
cross/redis/Makefile
cross/unzip/Makefile

@publicarray publicarray Sep 13, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A ripgrep version, I could not help myself:

$ rg --pcre2 -U -l -g 'cross/*/Makefile' '^(?=[\s\S]*\bCONFIGURE_TARGET\s*=\s*nop\b)(?=[\s\S]*GNU_CONFIGURE\s*=\s*1)[\s\S]*$'
cross/p7zip/Makefile
cross/unzip/Makefile
cross/ps3netsrv/Makefile
cross/redis/Makefile
cross/libcap/Makefile

The regex is thanks to https://stackoverflow.com/questions/469913/regular-expressions-is-there-an-and-operator#469951

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Personally I would like to see more smaller PRs if possible. IMHO you can leave them

@th0ma7 th0ma7 Sep 13, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

agreed, l'll do a different PR to manage that instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A ripgrep version, I could not help myself:

I so much need to learn to play with it :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@th0ma7 If you are interested in diving into alternatives like ripgrep, I recently found my 2nd favourite: fd an alternative to find and xh alternative httpie. For even more checkout: https://github.com/TaKO8Ki/awesome-alternatives-in-rust

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done with #4857

@publicarray

Copy link
Copy Markdown
Member

Thanks for this 👍 And I apologise for merging something that coursed these issues. I knew there was a risk but not to this degree.(I did my tests and those did pass, must have been lucky packages) Sorry. I think If only one or two packages needed a not parallel flag I still would have accepted the earlier PR...

This all started when I noticed compiling fish took too long 2.5 minutes as to less than a minute.

@publicarray

publicarray commented Sep 13, 2021 •

Copy link
Copy Markdown
Member

@th0ma7 kind reminder to revert the SPK_REV = changes.
building a few packages works. e.g. python38 in 6m11s. FYI ZNC and deluge have parts that are single threaded 👍

Comment thread mk/spksrc.native-env.mk
ENV += -u LDSHARED
ENV += -u MAKEFLAGS
ENV += -u PKG_CONFIG -u PKG_CONFIG_LIBDIR -u PKG_CONFIG_PATH
ENV := -u LDSHARED -u PKG_CONFIG -u PKG_CONFIG_LIBDIR -u PKG_CONFIG_PATH $(ENV)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think += is easier to understand than :=. Any reason for this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reason is, all the -u must be always at first as otherwise it pseudo-silently fails. As such := becomes the only way to ensure that.

I'll add a comment in the code for this...

@publicarray publicarray Sep 13, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks
IMHO unset variables or along those lines sounds better, but it doesn't matter that much

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done with #4857

@publicarray publicarray Sep 14, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not convinced, at least this wrong for Erlang. Both ENV += and ENV := work the same for this package. Only -u MAKEFLAGS was missing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fix is in #4858

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What needs to be happening for the later call is this:

env -u LDSHARED -u PKG_CONFIG -u PKG_CONFIG_LIBDIR -u PKG_CONFIG_PATH ...

But, as PARALLEL_MAKE was previously added to the environment prior to that, it becomes the first item in the list such as:

env PARALLEL_MAKE=max -u LDSHARED -u PKG_CONFIG -u PKG_CONFIG_LIBDIR -u PKG_CONFIG_PATH ...

And this ends-up throwing an error about the -u as unsetting variable needs to be first to the env call...

Question could then be, does PARALLEL_MAKE really needs to be part of $(ENV) or not? If not then we could switch back to += instead of :=. Although I don't recall the exact reason why it needed to be into $(ENV)... perhaps something worth investigating?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah ok thanks for the explanation 👍 we can leave it with := then.

@publicarray

publicarray commented Sep 13, 2021 •

Copy link
Copy Markdown
Member

Is it just me or does busybox just appear to hang there.

$ time make -C cross/busybox arch-x64-6.1
make: Entering directory '/spksrc/cross/busybox'
===>  Building package for arch x64-6.1
make build-arch-x64-6.1
make[1]: Entering directory '/spksrc/cross/busybox'
===>  Building package for arch x64-6.1
make[2]: Entering directory '/spksrc/cross/busybox'
===>  Set up toolchain 
env make --no-print-directory tc_vars > /spksrc/toolchain/syno-x64-6.1/work/tc_vars.mk 2>/dev/null;
===>  Downloading files for busybox
===>    File busybox-1.26.2.tar.bz2 already downloaded
===>  Verifying files for busybox
===>    Checking sha1sum of file busybox-1.26.2.tar.bz2
===>    Checking sha256sum of file busybox-1.26.2.tar.bz2
===>    Checking md5sum of file busybox-1.26.2.tar.bz2
/spksrc/cross/busybox/../../distrib/busybox-1.26.2.tar.bz2
===>  Processing dependencies of busybox
===>  Extracting for busybox
tar -xjpf /spksrc/cross/busybox/../../distrib/busybox-1.26.2.tar.bz2 -C /spksrc/cross/busybox/work-x64-6.1 
===>  Patching for busybox
patch -p0 < patches/100-start_stop_daemon.patch
patching file debianutils/start_stop_daemon.c
===>  Configuring for busybox
cp spksrc_defconfig /spksrc/cross/busybox/work-x64-6.1/busybox-1.26.2/configs/spksrc_defconfig
cat  | while IFS== read option value; do \
  sed -i -r -e "s/^(# )?$option.*$/$option=$value/" /spksrc/cross/busybox/work-x64-6.1/busybox-1.26.2/configs/spksrc_defconfig ; \
done

I think it's unrelated to this PR

@th0ma7

th0ma7 commented Sep 13, 2021

Copy link
Copy Markdown
Contributor Author

Thanks for this +1 And I apologise for merging something that coursed these issues. I knew there was a risk but not to this degree.(I did my tests and those did pass, must have been lucky packages) Sorry. I think If only one or two packages needed a not parallel flag I still would have accepted the earlier PR...

This all started when I noticed compiling fish took too long 2.5 minutes as to less than a minute.

Honestly this was on my todo list since day 1. I'm glad it finally works... but it did took way too many cycles to get there (as usual I guess). Now lets hope there isn't too many bugs lefts, but considering the amount of packages that succesfully built I think we are good to go!

@th0ma7

th0ma7 commented Sep 13, 2021

Copy link
Copy Markdown
Contributor Author

Is it just me or does busybox just appear to hang there.
I think it's unrelated to this PR

It is unrelated, busybox fails to build on its own as it requires specific parameters. You must use a package that depends on it to successfully build it.

@th0ma7
th0ma7 merged commit 7baf64c into SynoCommunity:master Sep 13, 2021
@fgma

fgma commented Sep 13, 2021

Copy link
Copy Markdown
Contributor

Just updated my branch. LGTM now.

@publicarray

publicarray commented Sep 13, 2021 •

Copy link
Copy Markdown
Member

Looking at the build logs we are not quite done yet unfortunately: https://github.com/SynoCommunity/spksrc/runs/3586108881
https://github.com/SynoCommunity/spksrc/runs/3586108956

java-11-openjdk rabbitmq worked before, not 100% sure on the others but deluge and minio should also have worked.

@th0ma7

th0ma7 commented Sep 13, 2021

Copy link
Copy Markdown
Contributor Author

Well, minio didn't for DSM7 on master, @fgma is working on solving that.
As for the others, I'll have a look at them (java-11-openjdk, rabbitmq and deluge).
As for squidguard, its been broken since quite a while.

@publicarray on that, would it be possible to mark some package as broken so they stop being built and fails?

@publicarray

Copy link
Copy Markdown
Member

I'm about to create a PR too, at least for java-11-openjdk

@publicarray

publicarray commented Sep 13, 2021 •

Copy link
Copy Markdown
Member

@publicarray on that, would it be possible to mark some package as broken so they stop being built and fails?

I think fixing them, moving them to diyspk or removing them if they are no longer supported by us would do. But no I don't think disabling them is a good way to deal with this.

@publicarray

publicarray commented Sep 13, 2021 •

Copy link
Copy Markdown
Member

Reviewing those PRs that address some of those packages was on my next thing to in my list. At the moment there is sickchill & salt I'm still working on reviewing. Honestly I think I'm going to spend time reviewing PRs for the foreseeable feature, we are getting close to 100 open PRs!

@th0ma7

th0ma7 commented Sep 13, 2021

Copy link
Copy Markdown
Contributor Author

Indeed there are way too many of them... Let me know where I can help (and I might as well just pick and choose).
In the meantime I wanted to focus on adressing ffmpeg and tvheadend pending issues... resulting in more PR.

AlexPresso pushed a commit to AlexPresso/spksrc that referenced this pull request Jan 30, 2025
* Fix logging to PSTAT at all MAKELEVEL

* PSTAT logging more specific with added [BEGIN] and [END] messages

* Re-uses @publicarray fix for cmake

* Move back to using cmake by default

* Move libaom only to using ninja by default

* When building multiple specific archs, force building native in sequence first (e.g. pre-build-native)

* Make all possible cross/* to use default COMPILE_TARGET to allow parallel build

* spk.mk: Add BEGIN-END flags along with SPK package name to pstat

* compile.mk: Fix warning: -j2 forced in makefile

* cmake.mk: Re-use solution from @publicarray

* cross-cc.mk: Improve messaging for pstat output

* spk.mk: Fix pre-build-native for multi-arch specific builds

When invoking make -j2 arch-armada38x it tries to build
both arch-arch-armada38x-6.1 and arch-arch-armada38x-7.0.
This fails when hitting native/* dependencies as they must
be built in sequence first, and only then switch to parallel
for all arch-* requested.

This issue was faced originally with make all-supported and
fixed by calling first pre-build-native as needed.  The change
here addresses this to allow the same building process when
multiple arch-* are passed by the user.

* libaom: Force ninja, leave everything else default to cmake

* busybox: Use ENV variable to allow using default COMPILE_TARGET

* native.mk: Ensure undefined variables are always first with -u flag

* cross/*: Remove all unnecessary COMPILE_TARGET

Many cross dependencies had unnecessary COMPILE_TARGET that can be
remove by using COMPILE_MAKE_OPTIONS.  This has the benefit of
call default compile target and thus using PARALLEL_MAKE flag
to benefit from all CPU when compiling.

* native/*: Remove all unnecessary COMPILE_TARGET

Allow passing MAKEFLAGS to native compile which enable parallel
building of all native dependencies, thus reducing compile time
significantly.

* native-env.mk: Add comment for undefined variables to be first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants