Closed epilsits closed 6 years ago
@epilsits See: https://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/CAJ127VwoVEXkZETwzowxXw-fK2O6sLmZF-6Si-7rM5E4q-efCw@mail.gmail.com/
Mingw's header is not up to date, I'll see if i can find a patch for that (or make one myself)
But that requires patching mingw itself.
I'm also currently rewriting the whole program so I probably won't push a commit (but leave a diff/patch in this issue)
Thank you for taking a look. For the time being I've rolled back to the previous commit to get it to build.
Not to pile on, but there's also something wrong with libgme recently. It builds, but during ffmpeg configure, it throws an error that libgme is not found. config.log seems to indicate some missing symbols / link failure.
Thanks for the hard work on this, I know ffmpeg is a beast. I really appreciate how this tool is organized, it's easier to understand and tweak than most.
@epilsits The rewrite should make it even easier, I went for single json files per package in that, makes it easier for me to maintain the core program.
But that's a bit out .. maybe a few months as I do not work on it that much.
About GME, can you post the error on gist/pastebin?
PS: Nvm, I saw gme updated.. they broke their stuff by forgetting to include zlib: Fixed by adding it post install, see here: https://github.com/DeadSix27/python_cross_compile_script/commit/5e116e568c75c8017ed137318fe11d9042cb99d3
EDIT: also reported here: https://bitbucket.org/mpyne/game-music-emu/issues/15/zlib-linking-on-mingw-missing-lz-in-pkg Let's see if my assumption was correct.
Awesome, thank you for the quick fix! ffmpeg is such a moving target...
@epilsits openal didn't work anymore either, but I updated its patches too: https://github.com/DeadSix27/python_cross_compile_script/commit/857a2283bdf079fdad2ae31a9b12fc2c37a41862
I'm really littering this thread... But one more I found, expat now requires to run 'aclocal' before automake. Their repo comes from automake 1.15.1 and automake 1.15 in Ubuntu complains.
@epilsits Do you have IRC or discord?
I don't. I can probably get something going if you need to chat though. I'm at work so will be a bit spotty.
Here's a working (?) icd_windows_hkr.h
. C isn't my strongest suit, so there are a few warnings I'm concerned about (declaring an extern and implicit function definitions).
#include <stdbool.h>
#include <guiddef.h>
bool khrIcdOsVendorsEnumerateHKR(void);
typedef unsigned long int DEVPROPTYPE, *PDEVPROPTYPE;
typedef GUID DEVPROPGUID, *PDEVPROPGUID;
typedef unsigned long int DEVPROPID, *PDEVPROPID;
typedef struct _DEVPROPKEY {
DEVPROPGUID fmtid;
DEVPROPID pid;
} DEVPROPKEY, *PDEVPROPKEY;
#define CM_GETIDLIST_FILTER_PRESENT (0x00000100)
#define CM_GETIDLIST_FILTER_CLASS (0x00000200)
#define DEFINE_DEVPROPKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) extern const DEVPROPKEY DECLSPEC_SELECTANY name = { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }, pid }
DEFINE_DEVPROPKEY(DEVPKEY_Device_ClassGuid, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 10); // DEVPROP_TYPE_GUID
Build tested successfully, I was able to encode with the h264_qsv encoder.
I think I'd suggest an additional product profile, ffmpeg_static_non_free (without OpenCL), just to cover the bases.
Looks like gme fixed zlib. Will test later.
Here's a working (?) icd_windows_hkr.h.
Thanks. Checking on your build process ... Provisionally subject to your comments about the C warnings, combine your icd_windows_hkr.h with this latest git source https://github.com/KhronosGroup/OpenCL-ICD-Loader and these build commands ?
'opencl_icd' : {
'repo_type' : 'git',
'url' : 'https://github.com/KhronosGroup/OpenCL-ICD-Loader.git',
'needs_configure' : False,
'needs_make_install':False,
'is_cmake' : True,
'cmake_options': '. {cmake_prefix_options} -DCMAKE_INSTALL_PREFIX={target_prefix} -DBUILD_SHARED_LIBS=OFF',
'depends_on' : [ 'opencl_headers' ],
'run_post_patch' : {
'sed -i.bak \'s/Devpkey.h/devpkey.h/\' icd_windows_hkr.c',
},
'run_post_make' : [
'if [ ! -f "already_ran_make_install" ] ; then cp -vf "libOpenCL.dll.a" "{target_prefix}/lib/libOpenCL.dll.a" ; fi',
'if [ ! -f "already_ran_make_install" ] ; then touch already_ran_make_install ; fi',
],
'patches' : [
('https://raw.githubusercontent.com/DeadSix27/python_cross_compile_script/master/patches/opencl/0001-OpenCL-git-prefix.patch','p1'),
],
},
'opencl_headers' : {
'repo_type' : 'git',
'url' : 'https://github.com/KhronosGroup/OpenCL-Headers.git',
'run_post_patch' : (
'if [ ! -f "already_ran_make_install" ] ; then if [ ! -d "{target_prefix}/include/CL" ] ; then mkdir "{target_prefix}/include/CL" ; fi ; fi',
'if [ ! -f "already_ran_make_install" ] ; then cp -v opencl22/CL/*.h "{target_prefix}/include/CL/" ; fi',
'if [ ! -f "already_ran_make_install" ] ; then touch already_ran_make_install ; fi',
),
'needs_make':False,
'needs_make_install':False,
'needs_configure':False,
},
and this patch
diff -Nur OpenCL-ICD-Loader_git/CMakeLists.txt OpenCL-ICD-Loader_git.patched/CMakeLists.txt
--- OpenCL-ICD-Loader_git/CMakeLists.txt 2017-04-22 16:24:31.188142113 +0200
+++ OpenCL-ICD-Loader_git.patched/CMakeLists.txt 2017-04-22 16:24:29.163896055 +0200
@@ -20,6 +20,7 @@
add_library (OpenCL SHARED ${OPENCL_ICD_LOADER_SOURCES})
set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
+set_target_properties (OpenCL PROPERTIES PREFIX "")
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-pthread -Wl,--version-script -Wl,${CMAKE_SOURCE_DIR}/icd_exports.ma
?
The reason I ask is that I ran into this back in October https://github.com/KhronosGroup/OpenCL-ICD-Loader/issues/23
and I noticed this pull request https://github.com/KhronosGroup/OpenCL-ICD-Loader/pull/27
@epilsits Ill check that out in a bit, I just read hydras report on their repo, guess their idea was to have a seperate header too (mingw patching it would be better though)
Thank you.
For my static build purposes, and building on DeadSix27's original work, here are the patches I had to apply to the commit I currently use : https://github.com/KhronosGroup/OpenCL-ICD-Loader.git commit "6849f617e991e8a46eebf746df43032175f263b3"
--- CMakeLists.txt 2017-08-25 06:52:42.796621000 -0700
+++ CMakeLists.new.txt 2017-08-25 06:52:42.796621000 -0700
@@ -22,8 +22,10 @@
include_directories (${OPENCL_INCLUDE_DIRS})
-add_library (OpenCL SHARED ${OPENCL_ICD_LOADER_SOURCES})
+#add_library (OpenCL SHARED ${OPENCL_ICD_LOADER_SOURCES})
+add_library (OpenCL STATIC ${OPENCL_ICD_LOADER_SOURCES})
set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
+set_target_properties (OpenCL PROPERTIES PREFIX "")
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-pthread -Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/icd_exports.map")
for win32 building only, also do :
--- icd_windows.c 2017-08-25 06:52:42.796621000 -0700
+++ icd_windows.new.c 2017-08-25 06:52:42.796621000 -0700
@@ -35,6 +35,8 @@
* OpenCL is a trademark of Apple Inc. used under license by Khronos.
*/
+#define _WIN32_WINNT 0x0600
+
#include "icd.h"
#include <stdio.h>
#include <windows.h>
@epilsits How did you get it to build without all of that ? I must be missing something :)
@hydra3333 You can open a seperate issue for your specific issue, as I think its not directly related
OK Thank you.
I seem to get an error building, ubuntu 17.10 mingw 5.0.3 patches and sed applied. I gather it works for you though. Any hint would be appreciated, although I'd understand if you'd rather not. I think I'd better run your script and look at the logs. ..
[ 38%] Building C object CMakeFiles/OpenCL.dir/icd_windows.c.obj
In file included from /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_windows.c:41:0:
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_windows_hkr.h:58:19: warning: ‘DEVPKEY_Device_ClassGuid’ initialised and declared ‘extern’
DEFINE_DEVPROPKEY(DEVPKEY_Device_ClassGuid, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 10); // DEVPROP_TYPE_GUID
^
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_windows_hkr.h:56:124: note: in definition of macro ‘DEFINE_DEVPROPKEY’
EFINE_DEVPROPKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) extern const DEVPROPKEY DECLSPEC_SELECTANY name = { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }, pid }
^~~~
[ 42%] Building C object CMakeFiles/OpenCL.dir/icd_windows_hkr.c.obj
In file included from /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_windows_hkr.c:39:0:
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_windows_hkr.h:58:19: warning: ‘DEVPKEY_Device_ClassGuid’ initialised and declared ‘extern’
DEFINE_DEVPROPKEY(DEVPKEY_Device_ClassGuid, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 10); // DEVPROP_TYPE_GUID
^
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_windows_hkr.h:56:124: note: in definition of macro ‘DEFINE_DEVPROPKEY’
EFINE_DEVPROPKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) extern const DEVPROPKEY DECLSPEC_SELECTANY name = { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }, pid }
^~~~
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_windows_hkr.c: In function ‘khrIcdOsVendorsEnumerateHKR’:
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_windows_hkr.c:336:23: warning: implicit declaration of function ‘CM_Get_DevNode_PropertyW’; did you mean ‘CM_Set_DevNode_Problem’? [-Wimplicit-function-declaration]
ret = CM_Get_DevNode_PropertyW(
^~~~~~~~~~~~~~~~~~~~~~~~
CM_Set_DevNode_Problem
[ 46%] Building RC object CMakeFiles/OpenCL.dir/OpenCL.rc.res
[ 50%] Linking C static library OpenCL.a
[ 50%] Built target OpenCL
Scanning dependencies of target icd_loader_test
[ 53%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_kernel.c.obj
[ 57%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/main.c.obj
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/test/loader_test/main.c: In function ‘main’:
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/test/loader_test/main.c:36:5: warning: implicit declaration of function ‘test_release_calls’; did you mean ‘test_create_calls’? [-Wimplicit-function-declaration]
test_release_calls();
^~~~~~~~~~~~~~~~~~
test_create_calls
[ 61%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_platforms.c.obj
[ 65%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/icd_test_match.c.obj
[ 69%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_program_objects.c.obj
[ 73%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_sampler_objects.c.obj
[ 76%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_buffer_object.c.obj
[ 80%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_cl_runtime.c.obj
[ 84%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/callbacks.c.obj
[ 88%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_create_calls.c.obj
[ 92%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_clgl.c.obj
[ 96%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_image_objects.c.obj
[100%] Linking C executable ../../bin/icd_loader_test.exe
../../OpenCL.a(icd_windows_hkr.c.obj):icd_windows_hkr.c:(.text+0x32c): undefined reference to `CM_Get_DevNode_PropertyW'
collect2: error: ld returned 1 exit status
test/loader_test/CMakeFiles/icd_loader_test.dir/build.make:396: recipe for target 'bin/icd_loader_test.exe' failed
make[2]: *** [bin/icd_loader_test.exe] Error 1
CMakeFiles/Makefile2:257: recipe for target 'test/loader_test/CMakeFiles/icd_loader_test.dir/all' failed
make[1]: *** [test/loader_test/CMakeFiles/icd_loader_test.dir/all] Error 2
Makefile:94: recipe for target 'all' failed
make: *** [all] Error 2
do_git_checkout https://github.com/KhronosGroup/OpenCL-Headers.git OpenCL-Headers
cd OpenCL-Headers || exit 1
mkdir -pv "${mingw_w64_x86_64_prefix}/include/CL"
mkdir -pv "${mingw_w64_x86_64_prefix}/include/OpenCL"
cd opencl22/CL || exit 1 # nvidia is v1.2 as at 2017.05.28 but the ICD loader requires latest
echo "--- START copying *.h to $mingw_w64_x86_64_prefix/include/CL/ ..."
cp -fv *.h "$mingw_w64_x86_64_prefix/include/CL/" || exit 1
echo "--- END copying *.h to $mingw_w64_x86_64_prefix/include/CL/ ..."
echo "--- START copying *.h to $mingw_w64_x86_64_prefix/include/OpenCL/ ..."
cp -fv *.h "$mingw_w64_x86_64_prefix/include/OpenCL/" || exit 1
echo "--- END copying *.h to $mingw_w64_x86_64_prefix/include/OpenCL/ ..."
cd ../..
cd ..
do_git_checkout https://github.com/KhronosGroup/OpenCL-ICD-Loader.git OpenCL-ICD-Loader # 6849f617e991e8a46eebf746df43032175f263b3 is last working commit before they broke it
cd OpenCL-ICD-Loader || exit 1
rm -fv "libOpenCL.dll.a"
rm -fv "$mingw_w64_x86_64_prefix/lib/libOpenCL.dll.a"
rm -fv "OpenCL.a"
rm -fv "$mingw_w64_x86_64_prefix/lib/OpenCL.a"
# 2018.02.02 from DeadSix27:
apply_patch https://raw.githubusercontent.com/hydra3333/ffmpeg-windows-build-helpers-withOpenCL/master/patches/0001-OpenCL-git-prefix-static.patch # "-p1"
apply_patch https://raw.githubusercontent.com/hydra3333/ffmpeg-windows-build-helpers-withOpenCL/master/patches/0001-OpenCL-git-header.patch "-p1"
if [ "$1" = "32" ]; then # this patch applies only to 32bit
# this patch apparently fixes the issue
# CMakeFiles/OpenCL.dir/objects.a(icd_windows.c.obj):icd_windows.c:(.text+0x143):
# undefined reference to `InitOnceExecuteOnce'
# collect2: error: ld returned 1 exit status
# CMakeFiles/OpenCL.dir/build.make:152: recipe for target 'bin/OpenCL.dll' failed
# make[2]: *** [bin/OpenCL.dll] Error 1
echo "inside build_openCL_icd_new_v2 and bits=$1 ... ALSO patching icd_windows.c to fix the issue \"undefined reference to 'InitOnceExecuteOnce'\""
apply_patch https://raw.githubusercontent.com/hydra3333/ffmpeg-windows-build-helpers-withOpenCL/master/patches/0001-OpenCL-icd-windows-c.patch #"-p1"
elif [ "$1" = "64" ]; then # this patch applies only to 64bit
echo "inside build_openCL_icd_new_v2 and bits=$1 ... no need to patch icd_windows.c "
else
echo "inside build_openCL_icd_new_v2 and bits=$1 which is not 32 or 64 !! Aborting."
exit 1
fi
# 3. make devpkey includable
# 2018.02.02 from DeadSix27: apparently devpkey.h is in mingw64,
# https://github.com/DeadSix27/python_cross_compile_script/issues/29#issue-292584111
# https://github.com/DeadSix27/python_cross_compile_script/pull/31#issuecomment-362291618
# https://github.com/DeadSix27/python_cross_compile_script/issues/29
echo "sed -i.bak 's/Devpkey.h/devpkey.h/' icd_windows_hkr.c"
echo "sed -i.bak 's/Devpkey.h/devpkey.h/' icd_windows_hkr.c" >> "${config_logfile}"
sed -i.bak 's/Devpkey.h/devpkey.h/' icd_windows_hkr.c || exit 1
# 4. Build it
echo "cmake –G”Unix Makefiles” . -DENABLE_STATIC_RUNTIME=1 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RANLIB=${cross_prefix}ranlib -DCMAKE_C_COMPILER=${cross_prefix}gcc -DCMAKE_CXX_COMPILER=${cross_prefix}g++ -DCMAKE_RC_COMPILER=${cross_prefix}windres -DCMAKE_INSTALL_PREFIX=$mingw_w64_x86_64_prefix -DBUILD_SHARED_LIBS=OFF -DCMAKE_FIND_ROOT_PATH=$mingw_w64_x86_64_prefix "
echo "cmake –G”Unix Makefiles” . -DENABLE_STATIC_RUNTIME=1 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RANLIB=${cross_prefix}ranlib -DCMAKE_C_COMPILER=${cross_prefix}gcc -DCMAKE_CXX_COMPILER=${cross_prefix}g++ -DCMAKE_RC_COMPILER=${cross_prefix}windres -DCMAKE_INSTALL_PREFIX=$mingw_w64_x86_64_prefix -DBUILD_SHARED_LIBS=OFF -DCMAKE_FIND_ROOT_PATH=$mingw_w64_x86_64_prefix " >> "${config_logfile}"
cmake –G”Unix Makefiles” . -DENABLE_STATIC_RUNTIME=1 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RANLIB=${cross_prefix}ranlib -DCMAKE_C_COMPILER=${cross_prefix}gcc -DCMAKE_CXX_COMPILER=${cross_prefix}g++ -DCMAKE_RC_COMPILER=${cross_prefix}windres -DCMAKE_INSTALL_PREFIX=$mingw_w64_x86_64_prefix -DBUILD_SHARED_LIBS=OFF -DCMAKE_FIND_ROOT_PATH=$mingw_w64_x86_64_prefix || exit 1
echo "make clean"
echo "make clean" >> "${config_logfile}"
make clean || exit 1
echo "make -j $cpu_count "
echo "make -j $cpu_count " >> "${config_logfile}"
make -j $cpu_count || exit 1
# 5. Copy the result to the right places
##cp -fv "libOpenCL.dll.a" "$mingw_w64_x86_64_prefix/lib/libOpenCL.dll.a" || exit 1
#cp -fv "OpenCL.a" "$mingw_w64_x86_64_prefix/lib/OpenCL.a" || exit 1 # brute force link success by copying to known .a filenames
#cp -fv "OpenCL.a" "$mingw_w64_x86_64_prefix/lib/libOpenCL.a" || exit 1 # brute force link success by copying to known .a filenames
echo "cp -fv \"OpenCL.a\" \"$mingw_w64_x86_64_prefix/lib/libOpenCL.dll.a\""
echo "cp -fv \"OpenCL.a\" \"$mingw_w64_x86_64_prefix/lib/libOpenCL.dll.a\"" >> "${config_logfile}"
cp -fv "OpenCL.a" "$mingw_w64_x86_64_prefix/lib/libOpenCL.dll.a" || exit 1 # brute force link success by copying to known .a filenames
cp -fv "OpenCL.a" "$mingw_w64_x86_64_prefix/lib/libOpenCL.a" || exit 1 # brute force link success by copying to known .a filenames
#read -p "Finished build_openCL_icd_new_v2, press Enter to continue... or control-C if not happy"
cd ..
}
@hydra3333 link to Cfgmgr32 (-lcfgmgr32)
OK, thank you. +1 to the diagnosis kitbag of things to look for when something doesn't go right.
I'm compiling on an Ubuntu 17.10 Docker image. When compiling the current version of OpenCL, it fails with errors about missing declarations in the headers. It is missing, for example, some CM_GETIDLIST_FILTER_CLASS (cfgmgr32.h) and related macros, and some definitions from devpkey.h. I can only assume this used to work, because your post patch command
sed -i.bak \'s/Devpkey.h/devpkey.h/\' icd_windows_hkr.c
is only applicable to the commit which broke the compile. Did something change with the gcc compiler that it's missing these headers?