Skip to content

Commit cf77d4e

Browse files
Merge pull request #2 from dgruss/ultrastardx
generate 64-bit DLLs (and update gcc for it to work)
2 parents 335e066 + 2a7b1fc commit cf77d4e

15 files changed

Lines changed: 531 additions & 70 deletions

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: Build
22

33
on: [push, pull_request]
44
jobs:
5-
build_i686:
6-
name: Build for 32 bit x86
5+
build_x86_64:
6+
name: Build for 64 bit x86_64
77
runs-on: ubuntu-22.04
88
steps:
99
- name: Install dependencies
@@ -40,7 +40,7 @@ jobs:
4040
- name: Collect Artifacts
4141
uses: actions/upload-artifact@v4
4242
with:
43-
name: usdx-dlls-i686
43+
name: usdx-dlls-x86_64
4444
path: DLLs/*
4545
if-no-files-found: error
4646
- name: Cleanup Download Cache

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/wip/
77
/tmp-*
88
/.ccache
9+
/DLLs/
910

1011
# generated by cmake projects
1112
CMakeCache.txt

build.sh

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,72 @@
11
#!/bin/sh
22
MXE=/tmp/mxe
3+
TARGET=x86_64-w64-mingw32.shared
4+
DLL_DIR=$MXE/DLLs
5+
PORTAUDIO_NAME=portaudio_x64
36
if [ "`pwd`" != $MXE ] ; then
47
echo Please clone this repository to /tmp/mxe for reproducible builds >&2
58
exit 1
69
fi
710
touch src/ffmpeg.mk src/dav1d.mk src/freetype-bootstrap.mk src/libjpeg-turbo.mk src/libpng.mk src/portaudio.mk src/sqlite.mk src/lua.mk src/sdl2.mk src/sdl2_image.mk src/zlib.mk src/libwebp.mk src/tiff.mk
811
export SOURCE_DATE_EPOCH=0
9-
make -j 2 JOBS=2 MXE_TARGETS=i686-w64-mingw32.shared ffmpeg sdl2_image freetype-bootstrap portaudio sqlite lua
10-
mkdir -p $MXE/DLLs
11-
for i in avcodec-61 avformat-61 avutil-59 swresample-5 swscale-8 libdav1d libjpeg-8 libpng16-16 libtiff-6 libwebp-7 SDL2 SDL2_image zlib1 lua54:lua5.4 libsqlite3-0:sqlite3 libfreetype-6:freetype6 libportaudio-2:portaudio_x86 ; do
12-
j=${i##*:}
13-
i=${i%%:*}
14-
$MXE/usr/bin/i686-w64-mingw32.shared-objcopy --only-keep-debug $MXE/usr/i686-w64-mingw32.shared/bin/$i.dll $MXE/DLLs/$j.debug
12+
# Replace local wrapper sources with USDX versions before building.
13+
USDX_RAW_BASE="https://raw.githubusercontent.com/UltraStar-Deluxe/USDX/2b0ffa2e5e90b30e35f9f8f178a07a32033f451f"
14+
fetch_wrapper() {
15+
url="$1"
16+
out="$2"
17+
if command -v curl >/dev/null 2>&1; then
18+
curl -fsSL "$url" -o "$out"
19+
return $?
20+
fi
21+
if command -v wget >/dev/null 2>&1; then
22+
wget -qO "$out" "$url"
23+
return $?
24+
fi
25+
echo "Missing curl/wget to fetch USDX wrappers" >&2
26+
return 1
27+
}
28+
mkdir -p src/opencvwrapper src/projectm-cwrapper
29+
fetch_wrapper "$USDX_RAW_BASE/src/lib/openCV3/ApiWrapper.cpp" \
30+
"src/opencvwrapper/opencv-wrapper.cpp"
31+
fetch_wrapper "$USDX_RAW_BASE/src/lib/projectM/cwrapper/projectM-cwrapper.cpp" \
32+
"src/projectm-cwrapper/projectM-cwrapper.cpp"
33+
fetch_wrapper "$USDX_RAW_BASE/src/lib/projectM/cwrapper/projectM-cwrapper.h" \
34+
"src/projectm-cwrapper/projectM-cwrapper.h"
35+
# Force DWARF debug info and assume .loc support to avoid stabs on x86_64.
36+
make MXE_TARGETS=$TARGET \
37+
CFLAGS_FOR_TARGET='-O2 -gdwarf-2 -gas-loc-support' \
38+
CXXFLAGS_FOR_TARGET='-O2 -gdwarf-2 -gas-loc-support' \
39+
ffmpeg sdl2_image freetype-bootstrap portaudio sqlite lua opencv opencvwrapper projectm projectm-cwrapper
40+
mkdir -p $DLL_DIR
41+
OBJ_COPY="$MXE/usr/bin/$TARGET-objcopy"
42+
add_dll() {
43+
dll="$1"
44+
base="$2"
45+
alias_opencv="$3"
46+
[ -x "$OBJ_COPY" ] || return 0
47+
[ -e "$dll" ] || return 0
48+
$OBJ_COPY --only-keep-debug "$dll" "$DLL_DIR/$base.debug"
1549
(
16-
cd $MXE/DLLs
17-
set -- `md5sum $j.debug`
18-
k=$j-$1
19-
mv $j.debug $k.debug
20-
$MXE/usr/bin/i686-w64-mingw32.shared-objcopy -S --add-gnu-debuglink=$k.debug $MXE/usr/i686-w64-mingw32.shared/bin/$i.dll $j.dll
21-
chmod a-x $j.dll $k.debug
50+
cd "$DLL_DIR"
51+
set -- `md5sum "$base.debug"`
52+
k=$base-$1
53+
mv "$base.debug" "$k.debug"
54+
$OBJ_COPY -S --add-gnu-debuglink="$k.debug" "$dll" "$base.dll"
55+
chmod a-x "$base.dll" "$k.debug"
56+
if [ "$alias_opencv" = "alias_opencv" ] && [ "${base#opencv_}" != "$base" ]; then
57+
cp "$base.dll" "lib$base.dll"
58+
fi
2259
)
60+
}
61+
for i in avcodec-61 avformat-61 avutil-59 swresample-5 swscale-8 libdav1d libjpeg-8 libpng16-16 libtiff-6 libwebp-7 SDL2 SDL2_image zlib1 lua54:lua libsqlite3-0:sqlite3 libfreetype-6 libportaudio-2:$PORTAUDIO_NAME libbz2 libdl libgcc_s_seh-1 libstdc++-6 libwinpthread-1; do
62+
j=${i##*:}
63+
i=${i%%:*}
64+
DLL_PATH="$MXE/usr/$TARGET/bin/$i.dll"
65+
add_dll "$DLL_PATH" "$j"
66+
done
67+
68+
# Add OpenCV and wrapper DLL(s) if present.
69+
for dll in "$MXE/usr/$TARGET/bin"/opencv_*.dll "$MXE/usr/$TARGET/bin"/libopencv_*.dll "$MXE/usr/$TARGET/bin"/opencvwrapper.dll "$MXE/usr/$TARGET/bin"/libprojectM*.dll "$MXE/usr/$TARGET/bin"/projectM-cwrapper.dll; do
70+
base=$(basename "$dll" .dll)
71+
add_dll "$dll" "$base"
2372
done

src/gcc-1-fixes.patch

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=b587c12551143c14f023860a1dbdf7
1212

1313
clang can build it correctly and this should probably be a feature test
1414

15-
diff --git a/gcc/config/i386/driver-i386.c b/gcc/config/i386/driver-i386.c
15+
diff --git a/gcc/config/i386/driver-i386.cc b/gcc/config/i386/driver-i386.cc
1616
index 1111111..2222222 100644
17-
--- a/gcc/config/i386/driver-i386.c
18-
+++ b/gcc/config/i386/driver-i386.c
17+
--- a/gcc/config/i386/driver-i386.cc
18+
+++ b/gcc/config/i386/driver-i386.cc
1919
@@ -26,7 +26,7 @@ along with GCC; see the file COPYING3. If not see
2020

2121
const char *host_detect_local_cpu (int argc, const char **argv);
@@ -36,20 +36,16 @@ diff --git a/gcc/config.gcc b/gcc/config.gcc
3636
index 1111111..2222222 100644
3737
--- a/gcc/config.gcc
3838
+++ b/gcc/config.gcc
39-
@@ -2207,7 +2207,7 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
40-
tmake_file="${tmake_file} i386/t-mingw-w32"
41-
;;
42-
esac
39+
@@
4340
- native_system_header_dir=/mingw/include
4441
+ native_system_header_dir=/include
45-
target_gtfiles="$target_gtfiles \$(srcdir)/config/i386/winnt.c"
46-
extra_options="${extra_options} i386/cygming.opt i386/mingw.opt"
47-
case ${target} in
42+
43+
4844
diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
4945
index 1111111..2222222 100644
5046
--- a/gcc/config/i386/mingw32.h
5147
+++ b/gcc/config/i386/mingw32.h
52-
@@ -198,7 +198,7 @@ along with GCC; see the file COPYING3. If not see
48+
@@ -207,7 +207,7 @@ along with GCC; see the file COPYING3. If not see
5349

5450
/* Override startfile prefix defaults. */
5551
#ifndef STANDARD_STARTFILE_PREFIX_1
@@ -58,7 +54,7 @@ index 1111111..2222222 100644
5854
#endif
5955
#ifndef STANDARD_STARTFILE_PREFIX_2
6056
#define STANDARD_STARTFILE_PREFIX_2 ""
61-
@@ -207,7 +207,7 @@ along with GCC; see the file COPYING3. If not see
57+
@@ -216,7 +216,7 @@ along with GCC; see the file COPYING3. If not see
6258
/* For native mingw-version we need to take care that NATIVE_SYSTEM_HEADER_DIR
6359
macro contains POSIX-style path. See bug 52947. */
6460
#undef NATIVE_SYSTEM_HEADER_DIR
@@ -81,22 +77,22 @@ diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h
8177
index 1111111..2222222 100644
8278
--- a/libgomp/libgomp.h
8379
+++ b/libgomp/libgomp.h
84-
@@ -69,6 +69,14 @@
80+
@@ -66,6 +66,13 @@
81+
# endif
8582
# endif
8683
#endif
87-
88-
+#include <stdio.h>
84+
+
8985
+#include <stdio.h>
9086
+#ifdef __MINGW_PRINTF_FORMAT
9187
+#define PRINTF_FORMAT __MINGW_PRINTF_FORMAT
9288
+#else
9389
+#define PRINTF_FORMAT printf
9490
+#endif
95-
+
91+
9692
#ifdef HAVE_ATTRIBUTE_VISIBILITY
9793
# pragma GCC visibility push(hidden)
9894
#endif
99-
@@ -173,7 +181,7 @@ team_free (void *ptr)
95+
@@ -168,7 +175,7 @@ extern void gomp_aligned_free (void *);
10096

10197
extern void gomp_vdebug (int, const char *, va_list);
10298
extern void gomp_debug (int, const char *, ...)
@@ -105,7 +101,7 @@ index 1111111..2222222 100644
105101
#define gomp_vdebug(KIND, FMT, VALIST) \
106102
do { \
107103
if (__builtin_expect (gomp_debug_var, 0)) \
108-
@@ -186,11 +194,11 @@ extern void gomp_debug (int, const char *, ...)
104+
@@ -182,11 +189,11 @@ extern void gomp_debug (int, const char *, ...)
109105
} while (0)
110106
extern void gomp_verror (const char *, va_list);
111107
extern void gomp_error (const char *, ...)

src/gcc-2-stabs.patch

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/gcc.mk

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ PKG := gcc
44
$(PKG)_WEBSITE := https://gcc.gnu.org/
55
$(PKG)_DESCR := GCC
66
$(PKG)_IGNORE :=
7-
$(PKG)_VERSION := 11.5.0
7+
$(PKG)_VERSION := 13.4.0
88
$(PKG)_RELEASE := $($(PKG)_VERSION)
9-
$(PKG)_CHECKSUM := a6e21868ead545cf87f0c01f84276e4b5281d672098591c1c896241f09363478
9+
$(PKG)_CHECKSUM := 9c4ce6dbb040568fdc545588ac03c5cbc95a8dbf0c7aa490170843afb59ca8f5
1010
$(PKG)_SUBDIR := gcc-$($(PKG)_VERSION)
1111
$(PKG)_FILE := gcc-$($(PKG)_VERSION).tar.xz
1212
$(PKG)_URL := https://ftp.gnu.org/gnu/gcc/gcc-$($(PKG)_VERSION)/$($(PKG)_FILE)
@@ -79,6 +79,9 @@ define $(PKG)_BUILD_mingw-w64
7979
--with-default-win32-winnt=0x0601 \
8080
$(mingw-w64-headers_CONFIGURE_OPTS)
8181
$(MAKE) -C '$(BUILD_DIR).headers' install
82+
# GCC fixincludes expects headers in $(TARGET)/mingw/include.
83+
mkdir -p '$(PREFIX)/$(TARGET)/mingw/include'
84+
cp -a '$(PREFIX)/$(TARGET)/include/.' '$(PREFIX)/$(TARGET)/mingw/include'
8285

8386
# build standalone gcc
8487
$($(PKG)_CONFIGURE)

src/libjpeg-turbo.mk

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ define $(PKG)_BUILD
2323
-DENABLE_STATIC=$(CMAKE_STATIC_BOOL) \
2424
-DWITH_JPEG8=ON \
2525
-DBUILD=reproducible \
26-
-DCMAKE_INSTALL_PREFIX='$(PREFIX)/$(TARGET)' \
27-
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
26+
-DCMAKE_INSTALL_PREFIX='$(PREFIX)/$(TARGET)' \
27+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
28+
-DCMAKE_C_FLAGS='-gdwarf-2' \
29+
-DCMAKE_CXX_FLAGS='-gdwarf-2' \
30+
-DCMAKE_ASM_NASM_FLAGS='-g null' \
31+
-DCMAKE_ASM_NASM_FLAGS_DEBUG='-g null' \
32+
-DCMAKE_ASM_NASM_FLAGS_RELEASE='-g null' \
33+
-DCMAKE_ASM_NASM_FLAGS_RELWITHDEBINFO='-g null' \
34+
-DCMAKE_ASM_NASM_FLAGS_MINSIZEREL='-g null' \
2835
-DCMAKE_ASM_NASM_COMPILER=$(TARGET)-yasm
2936
$(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)'
3037
$(MAKE) -C '$(BUILD_DIR)' -j 1 install

src/opencv.mk

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ $(PKG)_IGNORE :=
77
$(PKG)_VERSION := 4.6.0
88
$(PKG)_CHECKSUM := 1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
99
$(PKG)_GH_CONF := opencv/opencv/releases
10-
$(PKG)_DEPS := cc eigen ffmpeg jasper jpeg libpng libwebp \
11-
openblas openexr protobuf tiff xz zlib
10+
$(PKG)_DEPS := cc libjpeg-turbo
1211

1312
# -DCMAKE_CXX_STANDARD=98 required for non-posix gcc7 build
1413

@@ -17,28 +16,65 @@ define $(PKG)_BUILD
1716
cd '$(BUILD_DIR)' && '$(TARGET)-cmake' '$(SOURCE_DIR)' \
1817
-DWITH_QT=OFF \
1918
-DWITH_OPENGL=ON \
19+
-DWITH_FFMPEG=OFF \
2020
-DWITH_GSTREAMER=OFF \
2121
-DWITH_GTK=OFF \
2222
-DWITH_VIDEOINPUT=ON \
2323
-DWITH_XINE=OFF \
2424
-DWITH_LAPACK=OFF \
25+
-DWITH_EIGEN=OFF \
26+
-DWITH_OPENBLAS=OFF \
27+
-DWITH_IPP=OFF \
2528
-DBUILD_opencv_apps=OFF \
29+
-DBUILD_opencv_calib3d=OFF \
30+
-DBUILD_opencv_dnn=OFF \
2631
-DBUILD_DOCS=OFF \
2732
-DBUILD_EXAMPLES=OFF \
33+
-DBUILD_opencv_features2d=OFF \
34+
-DBUILD_opencv_flann=OFF \
35+
-DBUILD_opencv_gapi=OFF \
36+
-DBUILD_opencv_highgui=OFF \
37+
-DBUILD_opencv_java_bindings_generator=OFF \
38+
-DBUILD_opencv_ml=OFF \
39+
-DBUILD_opencv_objdetect=OFF \
40+
-DBUILD_opencv_photo=OFF \
41+
-DBUILD_opencv_python2=OFF \
42+
-DBUILD_opencv_python_bindings_generator=OFF \
43+
-DBUILD_opencv_python_tests=OFF \
2844
-DBUILD_PACKAGE=OFF \
2945
-DBUILD_PERF_TESTS=OFF \
46+
-DBUILD_opencv_stitching=OFF \
3047
-DBUILD_TESTS=OFF \
48+
-DBUILD_opencv_ts=OFF \
49+
-DBUILD_opencv_video=OFF \
3150
-DBUILD_WITH_DEBUG_INFO=OFF \
3251
-DBUILD_FAT_JAVA_LIB=OFF \
52+
-DCV_TRACE=OFF \
3353
-DBUILD_ZLIB=OFF \
3454
-DBUILD_TIFF=OFF \
3555
-DBUILD_JASPER=OFF \
3656
-DBUILD_JPEG=OFF \
3757
-DBUILD_WEBP=OFF \
3858
-DBUILD_PROTOBUF=OFF \
39-
-DPROTOBUF_UPDATE_FILES=ON \
4059
-DBUILD_PNG=OFF \
4160
-DBUILD_OPENEXR=OFF \
61+
-DWITH_JPEG=ON \
62+
-DWITH_PNG=OFF \
63+
-DWITH_TIFF=OFF \
64+
-DWITH_WEBP=OFF \
65+
-DWITH_JASPER=OFF \
66+
-DWITH_OPENJPEG=OFF \
67+
-DWITH_OPENEXR=OFF \
68+
-DWITH_PROTOBUF=OFF \
69+
-DWITH_ZLIB=OFF \
70+
-DWITH_ADE=OFF \
71+
-DWITH_QUIRC=OFF \
72+
-DWITH_GDAL=OFF \
73+
-DWITH_GDCM=OFF \
74+
-DWITH_IMGCODEC_HDR=OFF \
75+
-DWITH_IMGCODEC_SUNRASTER=OFF \
76+
-DWITH_IMGCODEC_PXM=OFF \
77+
-DWITH_IMGCODEC_PFM=OFF \
4278
-DCMAKE_VERBOSE=ON \
4379
-DOPENCV_GENERATE_PKGCONFIG=ON
4480

@@ -48,8 +84,4 @@ define $(PKG)_BUILD
4884

4985
$(INSTALL) -m755 '$(BUILD_DIR)/unix-install/opencv4.pc' '$(PREFIX)/$(TARGET)/lib/pkgconfig'
5086

51-
'$(TARGET)-g++' \
52-
-W -Wall -Werror -ansi -std=c++11 \
53-
'$(SOURCE_DIR)/samples/cpp/fback.cpp' -o '$(PREFIX)/$(TARGET)/bin/test-opencv.exe' \
54-
`'$(TARGET)-pkg-config' opencv4 libavcodec libavformat libswscale --cflags --libs` -lwebp
5587
endef

src/opencvwrapper.mk

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This file is part of MXE. See LICENSE.md for licensing information.
2+
3+
4+
PKG := opencvwrapper
5+
$(PKG)_WEBSITE := https://opencv.org/
6+
$(PKG)_DESCR := OpenCV C-wrapper for USDX
7+
$(PKG)_IGNORE :=
8+
$(PKG)_VERSION := 1
9+
$(PKG)_SUBDIR := opencvwrapper-src
10+
$(PKG)_SOURCE_TREE := $(TOP_DIR)
11+
$(PKG)_DEPS := cc opencv
12+
13+
# Build the USDX OpenCV wrapper as a DLL linked to OpenCV 4.x.
14+
define $(PKG)_BUILD
15+
'$(TARGET)-g++' -shared -o '$(PREFIX)/$(TARGET)/bin/opencvwrapper.dll' \
16+
'$(TOP_DIR)/src/opencvwrapper/opencv-wrapper.cpp' \
17+
-O2 -DNDEBUG \
18+
`$(TARGET)-pkg-config opencv4 --cflags --libs`
19+
endef

0 commit comments

Comments
 (0)