Skip to content

Commit 25f12e8

Browse files
committedFeb 19, 2021
Mingw64 ccache and debug sym fix
1 parent 09f53d1 commit 25f12e8

File tree

2 files changed

+88
-45
lines changed

2 files changed

+88
-45
lines changed
 

‎.github/workflows/minw64.yml

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: MinGW64 Windows Build
1+
name: MingW64 Windows 64bit Build
22

33
on:
44
push:
@@ -29,31 +29,72 @@ on:
2929

3030
jobs:
3131
build:
32+
env:
33+
CCACHE_DIR: ${{ github.workspace }}/.ccache
3234
name: MinGW64 Windows Build
3335
runs-on: ubuntu-latest
3436
steps:
3537

36-
- uses: actions/checkout@v1
38+
- uses: actions/checkout@v2
39+
3740
- name: Build Docker Container with Build Environment
3841
run: docker build -t qgis3-mingw-buildenv -f ms-windows/mingw/qgis3-build-deps-mingw.dockerfile .
3942

43+
- name: Prepare build cache for pull request
44+
uses: pat-s/always-upload-cache@v2.1.3
45+
if: github.event_name == 'pull_request'
46+
with:
47+
path: ${{ github.workspace }}/.ccache
48+
key: mingw64-ccache-${{ github.actor }}-${{ github.head_ref }}-${{ github.sha }}
49+
# The head_ref or source branch of the pull request in a workflow run.
50+
# The base_ref or target branch of the pull request in a workflow run.
51+
restore-keys: |
52+
mingw64-ccache-${{ github.actor }}-${{ github.head_ref }}-
53+
mingw64-ccache-${{ github.base_ref }}-
54+
mingw64-ccache-refs/heads/master-
55+
56+
- name: Prepare build cache for branch/tag
57+
# use a fork of actions/cache@v2 to upload cache even when the build or test failed
58+
uses: pat-s/always-upload-cache@v2.1.3
59+
if: github.event_name != 'pull_request'
60+
with:
61+
path: ${{ github.workspace }}/.ccache
62+
# The branch or tag ref that triggered the workflow run. For branches this in the format refs/heads/<branch_name>, and for tags it is refs/tags/<tag_name>
63+
key: mingw64-ccache-${{ github.ref }}-${{ github.sha }}
64+
restore-keys: |
65+
mingw64-ccache-${{ github.ref }}-
66+
mingw64-ccache-refs/heads/master-
67+
4068
- name: Build QGIS Application
41-
run: docker run -w /QGIS -v $PWD:/QGIS qgis3-mingw-buildenv ms-windows/mingw/build.sh x86_64 nodebug 4
69+
run: |
70+
docker run \
71+
--env CCACHE_DIR=/QGIS/.ccache \
72+
-w /QGIS \
73+
-v ${GITHUB_WORKSPACE}:/QGIS \
74+
qgis3-mingw-buildenv \
75+
ms-windows/mingw/build.sh x86_64 nodebug 4
76+
4277
- name: Create Portable zip
4378
run: |
44-
distroot=build_mingw64/dist/usr/x86_64-w64-mingw32/sys-root/mingw
45-
debugroot=dist_debug
46-
for file in $(find $distroot -name '*.debug' \( -type l -or -type f \)); do
47-
dest=${file/$distroot/$debugroot}
48-
mkdir -p "$(dirname $dest)"
49-
sudo mv "$file" "$dest"
79+
DISTROOT=build_mingw64/dist/usr/x86_64-w64-mingw32/sys-root/mingw
80+
DEBUGROOT=dist_debug
81+
for file in $(find $DISTROOT -name '*.debug' \( -type l -or -type f \)); do
82+
DEST=${file/$DISTROOT/$DEBUGROOT}
83+
mkdir -p "$(dirname $DEST)"
84+
sudo mv "$file" "$DEST"
5085
done
51-
sudo mv $distroot QGIS-Portable
86+
sudo mv $DISTROOT QGIS-Portable
5287
zip -r qgis-portable-win64.zip QGIS-Portable
53-
(cd $debugroot && zip -r - *) > qgis-portable-win64-debugsym.zip
88+
(cd $DEBUGROOT && zip -r - *) > qgis-portable-win64-debugsym.zip
5489
55-
- name: Upload Build Artifact
56-
uses: actions/upload-artifact@v1
90+
- name: Upload QGIS for Windows 64bit
91+
uses: actions/upload-artifact@v2.2.2
5792
with:
5893
name: QGIS for Windows 64bit
59-
path: qgis-windows-64bit.zip
94+
path: qgis-portable-win64.zip
95+
96+
- name: Upload QGIS for Windows 64bit Debug Symbols
97+
uses: actions/upload-artifact@v2.2.2
98+
with:
99+
name: QGIS for Windows 64bit Debug Symbols
100+
path: qgis-portable-win64-debugsym.zip

‎ms-windows/mingw/build.sh

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@
66

77
#!/bin/sh
88

9-
ARCH=${1:-x86_64}
9+
10+
arch=${1:-x86_64}
1011
DEBUG=false
11-
if [ "$2" == "DEBUG" ]; then
12+
if [ "$2" == "debug" ]; then
1213
DEBUG=true
1314
fi
14-
NJOBS=${3:-$(($(grep -c ^processor /proc/cpuinfo) * 3 / 2))}
15+
16+
njobs=${3:-$(($(grep -c ^processor /proc/cpuinfo) * 3 / 2))}
1517

1618

17-
if [ "$ARCH" == "i686" ]; then
19+
if [ "$arch" == "i686" ]; then
1820
bits=32
19-
elif [ "$ARCH" == "x86_64" ]; then
21+
elif [ "$arch" == "x86_64" ]; then
2022
bits=64
2123
else
22-
echo "Error: unrecognized ARCHitecture $ARCH"
24+
echo "Error: unrecognized architecture $arch"
2325
exit 1
2426
fi
2527

@@ -35,33 +37,34 @@ else
3537
fi
3638

3739
# Note: This script is written to be used with the Fedora mingw environment
38-
MINGWROOT=/usr/$ARCH-w64-mingw32/sys-root/mingw
40+
MINGWROOT=/usr/$arch-w64-mingw32/sys-root/mingw
3941

4042
if $DEBUG; then
41-
OPTFLAGS="-O0 -g1 -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -fno-omit-frame-pointer"
42-
buildtype="DEBUG"
43+
optflags="-O0 -g1 -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -fno-omit-frame-pointer"
44+
buildtype="Debug"
4345
else
44-
OPTFLAGS="-O2 -g1 -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -fno-omit-frame-pointer"
45-
buildtype="RelWithDEBUGInfo"
46+
optflags="-O2 -g1 -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -fno-omit-frame-pointer"
47+
buildtype="RelWithDebugInfo"
4648
fi
4749
pyver=$(mingw${bits}-python3 -c "import sys; print('.'.join(list(map(str, sys.version_info))[0:2]))")
4850

4951
# Halt on errors
5052
set -e
5153

52-
export MINGW32_CFLAGS="$OPTFLAGS"
53-
export MINGW32_CXXFLAGS="$OPTFLAGS"
54-
export MINGW64_CFLAGS="$OPTFLAGS"
55-
export MINGW64_CXXFLAGS="$OPTFLAGS"
54+
export MINGW32_CFLAGS="$optflags"
55+
export MINGW32_CXXFLAGS="$optflags"
56+
export MINGW64_CFLAGS="$optflags"
57+
export MINGW64_CXXFLAGS="$optflags"
5658

5759
SRCDIR="$(readlink -f "$(dirname "$(readlink -f "$0")")/../..")"
60+
5861
if $DEBUG; then
59-
BUILDDIR="$SRCDIR/build_mingw${bits}_DEBUG"
62+
BUILDDIR="$SRCDIR/build_mingw${bits}_debug"
6063
else
6164
BUILDDIR="$SRCDIR/build_mingw${bits}"
6265
fi
6366
installroot="$BUILDDIR/dist"
64-
installprefix="$installroot/usr/$ARCH-w64-mingw32/sys-root/mingw"
67+
installprefix="$installroot/usr/$arch-w64-mingw32/sys-root/mingw"
6568

6669
# Cleanup
6770
rm -rf "$installroot"
@@ -81,7 +84,6 @@ mkdir -p $BUILDDIR
8184
-DQWT_INCLUDE_DIR=$MINGWROOT/include/qt5/qwt \
8285
-DQSCI_SIP_DIR=$MINGWROOT/share/sip/PyQt5/Qsci/ \
8386
-DBUILD_TESTING=OFF \
84-
-DZSTD_INCLUDE_DIR=/usr/x86_64-w64-mingw32/sys-root/mingw/include/zstd/ \
8587
-DENABLE_TESTS=OFF \
8688
-DQGIS_BIN_SUBDIR=bin \
8789
-DQGIS_CGIBIN_SUBDIR=bin \
@@ -104,37 +106,37 @@ mkdir -p $BUILDDIR
104106
# cd $BUILDDIR/native_crssync
105107
# echo "Building native crssync..."
106108
# moc-qt5 $SRCDIR/src/core/qgsapplication.h > moc_qgsapplication.cpp
107-
# g++ $OPTFLAGS -fPIC -o crssync $SRCDIR/src/crssync/main.cpp $SRCDIR/src/crssync/qgscrssync.cpp moc_qgsapplication.cpp $SRCDIR/src/core/qgsapplication.cpp -DCORE_EXPORT= -DCOMPILING_CRSSYNC -I$SRCDIR/src/core/ -I$SRCDIR/src/core/geometry -I$BUILDDIR $(pkg-config --cflags --libs Qt5Widgets gdal sqlite3 proj)
109+
# g++ $optflags -fPIC -o crssync $SRCDIR/src/crssync/main.cpp $SRCDIR/src/crssync/qgscrssync.cpp moc_qgsapplication.cpp $SRCDIR/src/core/qgsapplication.cpp -DCORE_EXPORT= -DCOMPILING_CRSSYNC -I$SRCDIR/src/core/ -I$SRCDIR/src/core/geometry -I$BUILDDIR $(pkg-config --cflags --libs Qt5Widgets gdal sqlite3 proj)
108110
# )
109111
# crssync needs X at runtime
110112
# Xvfb :99 &
111113
# export DISPLAY=:99
112114

113-
mingw$bits-make -C$BUILDDIR -j$NJOBS DESTDIR="${installroot}" install VERBOSE=1
115+
mingw$bits-make -C$BUILDDIR -j$njobs DESTDIR="${installroot}" install VERBOSE=1
114116

115117
# Remove plugins with missing dependencies
116-
rm -rf ${installroot}/share/qgis/python/plugins/{MetaSeARCH,processing}
118+
rm -rf ${installroot}/share/qgis/python/plugins/{MetaSearch,processing}
117119

118-
# Strip DEBUGinfo
120+
# Strip debuginfo
119121
binaries=$(find $installprefix -name '*.exe' -or -name '*.dll' -or -name '*.pyd')
120122
for f in $binaries
121123
do
122-
case $(mingw-objdump -h $f 2>/dev/null | egrep -o '(DEBUG[\.a-z_]*|gnu.version)') in
123-
*DEBUGlink*) continue ;;
124-
*DEBUG*) ;;
124+
case $(mingw-objdump -h $f 2>/dev/null | egrep -o '(debug[\.a-z_]*|gnu.version)') in
125+
*debuglink*) continue ;;
126+
*debug*) ;;
125127
*gnu.version*)
126128
echo "WARNING: $(basename $f) is already stripped!"
127129
continue
128130
;;
129131
*) continue ;;
130132
esac
131133

132-
echo extracting DEBUG info from $f
133-
mingw-objcopy --only-keep-DEBUG $f $f.DEBUG || :
134+
echo extracting debug info from $f
135+
mingw-objcopy --only-keep-debug $f $f.debug || :
134136
pushd $(dirname $f)
135137
keep_symbols=`mktemp`
136-
mingw-nm $f.DEBUG --format=sysv --defined-only | awk -F \| '{ if ($4 ~ "Function") print $1 }' | sort > "$keep_symbols"
137-
mingw-objcopy --add-gnu-DEBUGlink=`basename $f.DEBUG` --strip-unneeded `basename $f` --keep-symbols="$keep_symbols" || :
138+
mingw-nm $f.debug --format=sysv --defined-only | awk -F \| '{ if ($4 ~ "Function") print $1 }' | sort > "$keep_symbols"
139+
mingw-objcopy --add-gnu-debuglink=`basename $f.debug` --strip-unneeded `basename $f` --keep-symbols="$keep_symbols" || :
138140
rm -f "$keep_symbols"
139141
popd
140142
done
@@ -160,7 +162,7 @@ function linkDep {
160162
lnk "$MINGWROOT/$1" "$destdir/$name" || return 1
161163
echo "${2:-bin}/$name: $(rpm -qf "$MINGWROOT/$1")" >> $installprefix/origins.txt
162164
autoLinkDeps "$destdir/$name" "${indent} " || return 1
163-
[ -e "$MINGWROOT/$1.DEBUG" ] && lnk "$MINGWROOT/$1.DEBUG" "$destdir/$name.DEBUG" || ($DEBUG && echo "Warning: missing $name.DEBUG" || :)
165+
[ -e "$MINGWROOT/$1.debug" ] && lnk "$MINGWROOT/$1.debug" "$destdir/$name.debug" || ($debug && echo "Warning: missing $name.debug" || :)
164166
return 0
165167
}
166168

@@ -243,7 +245,7 @@ cat $installprefix/origins.txt | sort | uniq > $installprefix/origins.new && mv
243245
# Create package
244246
DISTROOT=build_mingw64/dist/usr/x86_64-w64-mingw32/sys-root/mingw
245247
DEBUGROOT=dist_debug
246-
for file in $(find $DISTROOT -name '*.DEBUG' \( -type l -or -type f \)); do
248+
for file in $(find $DISTROOT -name '*.debug' \( -type l -or -type f \)); do
247249
dest=${file/$DISTROOT/$DEBUGROOT}
248250
mkdir -p "$(dirname $dest)"
249251
sudo mv "$file" "$dest"

0 commit comments

Comments
 (0)
Please sign in to comment.