Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Fix depends cross-compilation for macOS #2038

Merged
merged 14 commits into from
Mar 11, 2021

Conversation

cyrossignol
Copy link
Member

@cyrossignol cyrossignol commented Mar 6, 2021

This is a series of fixes and updates that clean up a huge mess in the depends system to allow for static cross-compilation and packaging of macOS artifacts with the project's built-in tools.

I updated several of the depends configurations from Bitcoin to help fix some of the underlying issues. This bumps the Qt version slightly from 5.9.6 to 5.9.8. Please expand the commit descriptions for details.

@cyrossignol cyrossignol changed the title Fix depends cross-compilation for macOS build: Fix depends cross-compilation for macOS Mar 6, 2021
@jamescowens jamescowens added this to the Ingrid milestone Mar 7, 2021
@jamescowens
Copy link
Member

This looks ready. Remove from draft?

@cyrossignol
Copy link
Member Author

Have a couple things left to clean up.

This fixes the macOS toolchain paths and relies on autotools to set the
path correctly instead of a legacy workaround.
With the update of our build/CI environment/scripts to Python 3, we
need to update the PYTHONPATH variable so that the macOS deployment
script can find the Python modules built by the depends recipes for
the packaging scripts.
bitcoin/bitcoin@76f52e3

This update supports fixes for building for macOS. It includes
additional tests for Qt modules used exclusively by Gridcoin.

As such, the "--enable-qt59" flag is now superfluous. It is no
longer required for static builds. The flag was a remnant from
a time when the project supported other Qt versions.

Note that this change removes support for Qt detection without
pkg-config. The tool must be available in the system.
Bitcoin's updated Qt autoconf macros expect that the pkg-config tool is
available. This removes the remaining configure.ac blocks that provided
an alternative to pkg-config to follow the upstream decision.
bitcoin/bitcoin@949c480

This update supports fixes needed to build the GUI for macOS using the
depends tools.
bitcoin/bitcoin@1112035

This updates to the latest Qt depends recipe from Bitcoin. It supports
fixes for build problems for the GUI on macOS. As a small side effect,
this upgrades the depends Qt version from 5.9.6 to 5.9.8.

Note that Qt 5.9 is not compatible with the macOS dark-mode feature. A
separate effort will upgrade the recipe to 5.12 or later to avoid some
display issues with Gridcoin's "native" theme on a dark-mode desktop.

This change also updates the Qt Charts and SVG modules of the original
Qt recipe for Gridcoin and removes the now unused ActiveQt module that
provided COM support for the legacy "neural network" on Windows.
This adds a top-level project to the Qt depends recipe that enables
the build system to generate the correct pkgconfig paths for all of
the platform targets.

Gridcoin uses the Charts and SVG modules in additon to the basic Qt
UI components needed upstream by Bitcoin. Some platform tool chains
ignored the invalid pkgconfig paths generated for these modules. To
fix the static Qt builds for every target, we need to address those
issues because the previous work-around for one broke another.
bitcoin/bitcoin@f9af3ce

This updates to the latest zlib depends recipe from Bitcoin to support
fixes for depends build problems for the GUI on macOS.
@cyrossignol cyrossignol force-pushed the mac-depends branch 2 times, most recently from c4bfade to 12831aa Compare March 9, 2021 03:31
@cyrossignol cyrossignol marked this pull request as ready for review March 9, 2021 04:52
@cyrossignol
Copy link
Member Author

cyrossignol commented Mar 9, 2021

Here are some 5.2.1.0 packages built with these changes:

gridcoin-5.2.1-macos.dmg
SHA256: 0c4be17ead9758cf4fce2934fec7491e56498ef06b202730ef0a4277c7bb5f90

This is a dynamically-linked GUI package for macOS 10.14 (Mojave) and above. It supports the system dark-mode and accent color appearance preferences with the "native" GUI theme.

gridcoin-5.2.1-macos-static.dmg
SHA256: 82d8bd16faeb90441feb20ddab4ebb48906e79076830e6705e168becbb6c64ae

This is a statically-linked GUI package that should support macOS as early as 10.11 (El Capitan). It does not support dark-mode.

gridcoinresearchd-5.2.1-macos
SHA256: d8e3e58e074a20a14e4d737012f1bc1f83900005e25c3072c3c46215575519ab

This is the statically-linked headless CLI executable. It should support macOS as early as 10.11. We have not distributed this in the past as far as I know.

@div72
Copy link
Member

div72 commented Mar 9, 2021

Could you remove doc/README_osx.MD?

bitcoin/bitcoin@f55eed2

This updates to the latest macOS deployment scripts from Bitcoin to fix
packaging issues when creating .dmg images with depends builds.
This removes:
  - native_biplist
  - native_cdrkit (replaced by native_libdmg-hfsplus)

Bitcoin's newer macOS packaging tools do not need these dependencies
anymore.
Because we couldn't cross-compile the macOS GUI with the depends system,
the CI configuration built the headless binary only. This re-enables the
GUI portion of the build.
The install_db4.sh tool is useful for obtaining the 4.8 version of
the Berkeley DB library needed for the wallet database. We add the
script here specifically to support macOS CI for GitHub Actions. A
quirk exists between the Xcode environment on the platform and the
berkeley-db4 Homebrew formula that causes the wallet tests to fail
when linked against Homebrew's recent build of BDB 4.8.

Instead of relying on the formula, we call the install_db4.sh tool
to install the dependency. This will build Berkeley DB without the
replication feature that exhibits this problem.

In the future, we may be able to return to installing the Homebrew
package to save time if the formula resolves the issue.
Gridcoin's "native" theme renders the GUI with the system appearance. On
macOS 10.14 (Mojave) and later, this appearance includes a user's accent
color and dark-mode preference.

However, those appearance preferences require Qt 5.12+. Background color
mismatches and display artifacts are visible when compiled using earlier
Qt versions. Because our current depends recipe targets Qt 5.9.8, static
builds for macOS exhibit these display issues.

This change adds detection for Qt versions earlier than 5.12 to fallback
to a macOS appearance mode that ignores the newer preferences on systems
that could otherwise support them.
@cyrossignol
Copy link
Member Author

@div72 Good call. I merged some useful bits into contrib/macdeploy/README.md and squashed.

Copy link
Member

@jamescowens jamescowens left a comment

Choose a reason for hiding this comment

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

Headache generating. Looks good to me.

Copy link
Member

@div72 div72 left a comment

Choose a reason for hiding this comment

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

utACK

@jamescowens jamescowens merged commit e1dde13 into gridcoin-community:development Mar 11, 2021
@cyrossignol cyrossignol deleted the mac-depends branch March 12, 2021 01:49
cyrossignol added a commit to cyrossignol/Gridcoin-Research that referenced this pull request Mar 14, 2021
Gridcoin added a top-level Qt SUBDIRS-type project in gridcoin-community#2038 (6f090a0)
to manage auxillary Qt modules needed by the project, and this causes
Qt to generate a .qmake.stash file in the depends directory. The file
contains a cache of qmake build variables which can cause issues with
subsequent static builds that target a different platform or SDK than
those selected for the previous depends build.

This ensures that the Qt recipe clears the stash file when rebuilding
the Qt packages, and qmake will regenerate it as needed.
@Git-Jiro
Copy link
Contributor

Hi @cyrossignol
can you share the commands (autogen, configure and make flags) you used to build the static DMG?
A lot of users are craving for binaries that support older macOS versions.
I would like to include a DMG with the statically linked binary at https://github.com/Git-Jiro/homebrew-jiro build

@cyrossignol
Copy link
Member Author

@Git-Jiro The commands are in this doc. The trickiest bit is getting a specific Xcode SDK version to build against. Due to licensing, we cannot endorse a distribution of the SDKs. You can look at the CI scripts for hints if you're creating your own pipeline.

Note that static build support for macOS is only complete on the development branch right now. You can merge this PR into master if you want to work on the build before the next release. Some of the improvements here also apply to dynamic builds, so you may be able to adapt your formula to use make deploy to create the DMG.

jamescowens added a commit to jamescowens/Gridcoin-Research that referenced this pull request Apr 4, 2021
Added
 - doc: Invite users to donate to Gridcoin Foundation gridcoin-community#1997 (@smoe)
 - rpc: Add "getburnreport" RPC function gridcoin-community#2049 (@cyrossignol)
 - gui: Add stats export reminder to beacon wizard auth page gridcoin-community#2050 (@cyrossignol)
 - doc: Add undocumented "-showorphans" GUI option to help text gridcoin-community#2058 (@cyrossignol)
 - beacon: Cull beacon db memory (passivation) gridcoin-community#2069 (@jamescowens)
 - gui: Avoid refreshing GUI researcher status while out-of-sync gridcoin-community#2068 (@cyrossignol)
 - consensus: Reimplement checkpoint-based spam protection gridcoin-community#2084 (@cyrossignol)
 - consensus: Verify hardened checkpoints on start up gridcoin-community#2087 (@cyrossignol)

Changed
 - test: autogenerate data headers gridcoin-community#2030 (@div72)
 - doc: Change copyright years to 2021 gridcoin-community#2042 (@caraka)
 - gui: Clarify overview page "stake" field gridcoin-community#2056 (@cyrossignol)
 - doc: Update Copyright headers gridcoin-community#2059 (@barton2526)
 - gui: Update Qt Linguist localization files gridcoin-community#2063 (@cyrossignol)
 - build: update dependencies gridcoin-community#2064 (@barton2526)
 - net: Reduce default connection limit back to 125 gridcoin-community#2066 (@cyrossignol)
 - build: openssl patch gridcoin-community#2074 (@barton2526)
 - translation: Translate /src/qt/locale/bitcoin_en.ts in pt_PT gridcoin-community#2083 (@DjMVeiga)
 - log: Adjust logging gridcoin-community#2076 (@jamescowens)
 - gui: Change scraper tab to Inconsolata monospace font gridcoin-community#2085 (@jamescowens)
 - researcher: Change beacon deferment fix to reference nActiveBeforeSB gridcoin-community#2092 (@jamescowens)

Removed
 - net: Clean up mandatory protocol version transition gridcoin-community#2080 (@cyrossignol)
 - refactor: Remove LessVerbose() function gridcoin-community#2089 (@cyrossignol)

Fixed
 - build: Fix depends cross-compilation for macOS gridcoin-community#2038 (@cyrossignol)
 - build: Deal with Qt depends .qmake.stash file gridcoin-community#2048 (@cyrossignol)
 - beacon: Fix a subtle error in renewal chain walker gridcoin-community#2054 (@jamescowens)
 - researcher: Fix "malformed CPID" status for some pool projects gridcoin-community#2052 (@cyrossignol)
 - lint: Misc Typos gridcoin-community#2060 (@barton2526)
 - lint: remove identified duplicate includes gridcoin-community#2061 (@barton2526)
 - gui: Fix splash screen block height progress gridcoin-community#2057 (@cyrossignol)
 - gui: Fix garbage placeholders in some tx notification localizations gridcoin-community#2070 (@cyrossignol)
 - build: Patch libzip to fix mingw compile regression for mingw 9.2+ gridcoin-community#2082 (@jamescowens)
 - gui: Fix shutdown response for failed core init gridcoin-community#2088 (@cyrossignol)
 - researcher: Fix deferment of beacon renewal in superblock window gridcoin-community#2090 (@cyrossignol)
 - gui: Fix typo in beacon status refresh gridcoin-community#2091 (@div72)
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.

None yet

4 participants