asb2m10 / jsusfx

Opensource Jesusonic FX implementation
Other
69 stars 13 forks source link

Msys2 MinGW64 compilation #34

Open Lucarda opened 4 years ago

Lucarda commented 4 years ago

Hi,

I'm trying to compile the Pd objects for windows 64 bit. No hurries :)

I do and get:

Lucarda@T410 MINGW64 /d/00-volatil/jsusfx/pd
$ cmake -G "MSYS Makefiles" -D CMAKE_C_COMPILER=D:/msys64/mingw64/bin/gcc.exe -D CMAKE_CXX_COMPILER=D:/msys64/mingw64/bin/g++.exe .
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
-- Check for working C compiler: D:/msys64/mingw64/bin/gcc.exe
-- Check for working C compiler: D:/msys64/mingw64/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: D:/msys64/mingw64/bin/g++.exe
-- Check for working CXX compiler: D:/msys64/mingw64/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: D:/00-volatil/jsusfx/pd

Lucarda@T410 MINGW64 /d/00-volatil/jsusfx/pd
$ make install
Scanning dependencies of target jsusfx
[  7%] Building CXX object D:/00-volatil/jsusfx/src/CMakeFiles/jsusfx.dir/jsusfx.cpp.obj
In file included from D:/00-volatil/jsusfx/src/jsusfx.cpp:19:
D:/00-volatil/jsusfx/src/jsusfx_file.h:128:19: warning: ignoring attributes on template argument 'EEL_F' {aka 'double'} [-Wignored-attributes]
  128 |  std::vector<EEL_F> vars;
      |                   ^
[ 14%] Building CXX object D:/00-volatil/jsusfx/src/CMakeFiles/jsusfx.dir/jsusfx_file.cpp.obj
In file included from D:/00-volatil/jsusfx/src/jsusfx_file.cpp:18:
D:/00-volatil/jsusfx/src/jsusfx_file.h:128:19: warning: ignoring attributes on template argument 'EEL_F' {aka 'double'} [-Wignored-attributes]
  128 |  std::vector<EEL_F> vars;
      |                   ^
[ 21%] Building CXX object D:/00-volatil/jsusfx/src/CMakeFiles/jsusfx.dir/jsusfx_gfx.cpp.obj
[ 28%] Building CXX object D:/00-volatil/jsusfx/src/CMakeFiles/jsusfx.dir/jsusfx_serialize.cpp.obj
[ 35%] Building CXX object D:/00-volatil/jsusfx/src/CMakeFiles/jsusfx.dir/riff.cpp.obj
[ 42%] Building C object D:/00-volatil/jsusfx/src/CMakeFiles/jsusfx.dir/WDL/eel2/nseel-compiler.c.obj
[ 50%] Building C object D:/00-volatil/jsusfx/src/CMakeFiles/jsusfx.dir/WDL/eel2/nseel-eval.c.obj
[ 57%] Building C object D:/00-volatil/jsusfx/src/CMakeFiles/jsusfx.dir/WDL/eel2/nseel-ram.c.obj
[ 64%] Building C object D:/00-volatil/jsusfx/src/CMakeFiles/jsusfx.dir/WDL/eel2/nseel-yylex.c.obj
[ 71%] Building C object D:/00-volatil/jsusfx/src/CMakeFiles/jsusfx.dir/WDL/eel2/nseel-cfunc.c.obj
D:\msys64\tmp\ccQYJwpg.s: Assembler messages:
D:\msys64\tmp\ccQYJwpg.s:263: Error: operand type mismatch for `call'
D:\msys64\tmp\ccQYJwpg.s:304: Error: operand type mismatch for `call'
D:\msys64\tmp\ccQYJwpg.s:344: Error: invalid instruction suffix for `push'
D:\msys64\tmp\ccQYJwpg.s:345: Error: invalid instruction suffix for `push'
D:\msys64\tmp\ccQYJwpg.s:346: Error: operand type mismatch for `call'
D:\msys64\tmp\ccQYJwpg.s:431: Error: operand type mismatch for `fmul'
D:\msys64\tmp\ccQYJwpg.s:438: Error: operand type mismatch for `fadd'
D:\msys64\tmp\ccQYJwpg.s:475: Warning: translating to `fstp %st(0)'
D:\msys64\tmp\ccQYJwpg.s:978: Warning: translating to `faddp'
D:\msys64\tmp\ccQYJwpg.s:1099: Warning: translating to `fsubrp'
D:\msys64\tmp\ccQYJwpg.s:1220: Warning: translating to `fmulp'
D:\msys64\tmp\ccQYJwpg.s:1341: Warning: translating to `fdivrp'
D:\msys64\tmp\ccQYJwpg.s:1378: Warning: translating to `fdivp'
D:\msys64\tmp\ccQYJwpg.s:1426: Warning: translating to `fdivp'
D:\msys64\tmp\ccQYJwpg.s:2105: Error: operand type mismatch for `call'
D:\msys64\tmp\ccQYJwpg.s:2146: Error: operand type mismatch for `call'
D:\msys64\tmp\ccQYJwpg.s:2188: Error: operand type mismatch for `call'
D:\msys64\tmp\ccQYJwpg.s:2226: Warning: translating to `fsubp'
D:\msys64\tmp\ccQYJwpg.s:2351: Warning: translating to `fsubp'
D:\msys64\tmp\ccQYJwpg.s:2763: Error: invalid instruction suffix for `push'
D:\msys64\tmp\ccQYJwpg.s:2764: Error: invalid instruction suffix for `push'
D:\msys64\tmp\ccQYJwpg.s:2766: Error: invalid instruction suffix for `push'
D:\msys64\tmp\ccQYJwpg.s:2767: Error: invalid instruction suffix for `push'
D:\msys64\tmp\ccQYJwpg.s:2768: Error: operand type mismatch for `call'
D:\msys64\tmp\ccQYJwpg.s:2812: Error: operand type mismatch for `call'
D:\msys64\tmp\ccQYJwpg.s:2852: Error: invalid instruction suffix for `push'
D:\msys64\tmp\ccQYJwpg.s:2853: Error: invalid instruction suffix for `push'
D:\msys64\tmp\ccQYJwpg.s:2854: Error: invalid instruction suffix for `push'
D:\msys64\tmp\ccQYJwpg.s:2855: Error: operand type mismatch for `call'
D:\msys64\tmp\ccQYJwpg.s:2898: Error: operand type mismatch for `call'
D:\msys64\tmp\ccQYJwpg.s:2938: Error: invalid instruction suffix for `push'
D:\msys64\tmp\ccQYJwpg.s:2939: Error: invalid instruction suffix for `push'
D:\msys64\tmp\ccQYJwpg.s:2940: Error: operand type mismatch for `call'
D:\msys64\tmp\ccQYJwpg.s:2982: Error: operand type mismatch for `call'
D:\msys64\tmp\ccQYJwpg.s:3033: Error: invalid instruction suffix for `push'
D:\msys64\tmp\ccQYJwpg.s:3034: Error: invalid instruction suffix for `push'
D:\msys64\tmp\ccQYJwpg.s:3035: Error: operand type mismatch for `call'
D:\msys64\tmp\ccQYJwpg.s:3082: Error: operand type mismatch for `call'
make[2]: *** [/D/00-volatil/jsusfx/src/CMakeFiles/jsusfx.dir/build.make:180: D:/00-volatil/jsusfx/src/CMakeFiles/jsusfx.dir/WDL/eel2/nseel-cfunc.c.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:127: D:/00-volatil/jsusfx/src/CMakeFiles/jsusfx.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

?

jpcima commented 3 years ago

@Lucarda it's been a long time since the request, but perhaps you can check if my PR #37 fixes this problem?

Lucarda commented 3 years ago

I did a quick test but now I got:

$ make install
[  6%] Generating WDL/eel2/asm-nseel-x64.obj
/bin/sh: php: command not found
make[2]: *** [/E/git-portable/jsusfx/src/CMakeFiles/jsusfx.dir/build.make:62: E:/git-portable/jsusfx/src/WDL/eel2/asm-nseel-x64.obj] Error 127
make[1]: *** [CMakeFiles/Makefile2:126: E:/git-portable/jsusfx/src/CMakeFiles/jsusfx.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

I don't have php. Never had it. Not sure how to install it.

jpcima commented 3 years ago

Hmm right msys doesn't have it. I did because I make a cross-compilation based on linux. It'd be nice if jsusfx would allow to use the prebuilts, then it would require neither php nor nasm to build.

I'll make some work towards that in a branch. Another thing is that the upstream has received support of ARM64. While at it, I consider adding this support, and also universal binary.

Lucarda commented 3 years ago

Let me know when ready for another test. :)

jpcima commented 3 years ago

@Lucarda You could give my current fork a try, it drops the php requirement. https://github.com/jpcima/jsusfx

Lucarda commented 3 years ago

I'm getting this:

cmake -G "MSYS Makefiles" -D CMAKE_C_COMPILER=G:/msys64/mingw64/bin/gcc.exe -D CMAKE_CXX_COMPILER=G:/msys64/mingw64/bin/g++.exe .

make install

...
[ 85%] Linking CXX static library libjsusfx.a
[ 85%] Built target jsusfx
Scanning dependencies of target jsusfx_pd_project
[ 92%] Building CXX object CMakeFiles/jsusfx_pd_project.dir/jsusfx_pd.cpp.obj
g++.exe: error: G:/msys64/DPD_LONGINTTYPE=long long: No such file or directory
make[2]: *** [CMakeFiles/jsusfx_pd_project.dir/build.make:63: CMakeFiles/jsusfx_pd_project.dir/jsusfx_pd.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:77: CMakeFiles/jsusfx_pd_project.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

could g++.exe: error: G:/msys64/DPD_LONGINTTYPE=long long: No such file or directory

be replaced with: -DPD_LONGINTTYPE=__int64 somewhere?

https://github.com/pure-data/pd-lib-builder/blob/master/Makefile.pdlibbuilder#L579

Lucarda commented 3 years ago

If i'm correct the pd.build part is not supposed to work under MINGW but on MSVC.

https://github.com/pierreguillot/pd.build/blob/674c969e39ad3e8fbd38f344488c8bac3667ce6e/pd.cmake#L53

jpcima commented 3 years ago

Perhaps it helps to replace "/D" with "-D" on that exact line.

Lucarda commented 3 years ago

I have done that and suppressed:

    # Generate the function to export for Windows
    #if(${WIN32})
    #   string(REPLACE "~" "_tilde" EXPORT_FUNCTION "${EXTERNAL_NAME}_setup")
    #   set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS #"/export:${EXPORT_FUNCTION}")
    #endif()

in pd.cmake.

Now I got undefined reference .. in the linking stage. On Windows we link to pd[.lib][.dll] and in this case had to link to libjsusfx~.dll.a ?

Dont know how to do that in Cmake.

ff1

jpcima commented 3 years ago

It will need a mingw alternative to that part your commented. It's that one that lets the dll know that these missing symbols would be found inside pd.exe.

But that part of pd.build is msvc-only. Perhaps you can make something of my external builder which has mingw support. mingw's dlltool can serve to change a def file into an implib. https://github.com/jpcima/pd-externals/blob/9fe8bbaaff32200e613b5cc6ee8c3a6823eac2ea/cmake/PdExternal.cmake#L13-L30

Lucarda commented 3 years ago

would be found inside pd.exe.

In the current build system Pd symbols are found in pd.build/x64/ in the pd.lib and for MSVC also on pd.def

MINGW is happy finding the symbols in pd.dll (this is how is done with pd-lib-builder.)

Lucarda commented 3 years ago

This is how the linking is done in pd-lib-builder

https://github.com/pure-data/pd-lib-builder/blob/master/Makefile.pdlibbuilder#L590

Lucarda commented 3 years ago

If i'm not mistaken MINGW can statically link to an .a file.

jpcima commented 3 years ago

Yes that's what the code would produce, a linkable .a file. You can make these by command-line too

x86_64-w64-mingw32-dlltool -l x64/libpd.dll.a x64/pd.def
i686-w64-mingw32-dlltool -l x86/libpd.dll.a x86/pd.def
Lucarda commented 3 years ago

I got the libjsusfx~.dll.a file. MINGW needs to link jsusfx~.dll with that and pd.lib. Is the above correct?

Lucarda commented 3 years ago

I tried to build it with https://github.com/pure-data/pd-lib-builder and it went really good with this makefile:

# library name
lib.name = jsusfx~

CPPFLAGS += -DEEL_TARGET_PORTABLE=1 -DWDL_FFT_REALSIZE=8 -I./src -I./src/WDL -I./src/WDL/eel2 -I./pd

common.sources = \
src/jsusfx.cpp \
src/jsusfx_file.cpp \
src/jsusfx_gfx.cpp \
src/jsusfx_serialize.cpp \
src/riff.cpp \
src/WDL/eel2/nseel-compiler.c \
src/WDL/eel2/nseel-eval.c \
src/WDL/eel2/nseel-ram.c \
src/WDL/eel2/nseel-yylex.c \
src/WDL/eel2/nseel-cfunc.c \
src/WDL/fft.c \

jsusfx~.class.sources = \
pd/jsusfx_pd.cpp \

datafiles = \

# include Makefile.pdlibbuilder
# (for real-world projects see the "Project Management" section
# in tips-tricks.md)
PDLIBBUILDER_DIR=./pd-lib-builder
include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder

May be the -I includes are not necessary.

I can upload here the binary for Windows64. Seems to be working fine here.

snobbiggie commented 1 year ago

I can upload here the binary for Windows64. Seems to be working fine here.

Is that an ongoing offer, perchance?

Lucarda commented 1 year ago

Is that an ongoing offer, perchance?

no.