Skip to content

Commit fbac56f

Browse files
Fastigiummessmerdtresf
authored
Fix VST crashes on Linux (#7987)
Pass winebuild param to disable dynamicbase/aslr Requires bleeding-edge wine version See also https://gitlab.winehq.org/wine/wine/-/merge_requests/8786 --------- Co-authored-by: Dalton Messmer <[email protected]> Co-authored-by: Tres Finocchiaro <[email protected]>
1 parent dec6a04 commit fbac56f

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

plugins/VstBase/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ foreach(var ${export_variables})
4747
_export_var_to_external(${var})
4848
endforeach()
4949

50+
# If we're building wine-powered RemoteVstPlugins for Linux,
51+
# use a custom winebuild to fix ASLR-related VST crashes.
52+
# See upstream bug report: https://bugs.winehq.org/show_bug.cgi?id=58480
53+
if(LMMS_BUILD_LINUX AND (LMMS_HAVE_VST_32 OR LMMS_HAVE_VST_64))
54+
ExternalProject_Add(wine
55+
GIT_REPOSITORY https://github.com/tresf/wine
56+
GIT_TAG 1f8bb63e75baa5c9f901c8f50b4ea9dd69e0baa0
57+
GIT_SHALLOW ON
58+
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/wine"
59+
SOURCE_SUBDIR tools/winebuild
60+
BUILD_ALWAYS ON
61+
BUILD_IN_SOURCE ON
62+
INSTALL_COMMAND ""
63+
)
64+
ExternalProject_Get_Property(wine SOURCE_DIR)
65+
set(CUSTOM_WINEBUILD_EXECUTABLE "${SOURCE_DIR}/tools/winebuild/winebuild")
66+
message(STATUS "Using custom winebuild: ${CUSTOM_WINEBUILD_EXECUTABLE}")
67+
endif()
68+
5069
# build 32 bit version of RemoteVstPlugin
5170
if(LMMS_HAVE_VST_32)
5271
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/RemoteVstPlugin32.cmake")

plugins/VstBase/RemoteVstPlugin/CMakeLists.txt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,12 @@ if(MSVC)
7272
endif()
7373

7474
# If we're building a Windows executable, add linker flags to disable ASLR
75-
# This is needed because several old VST dlls crash when ASLR is in use (see bug #7830)
75+
# This is needed because several old VST dlls crash when high entropy ASLR is in use
76+
# /HIGHENTROPYVA:YES relies on /DYNAMICBASE:YES so this ensures maximum VST compatiblity
7677
if(MSVC)
7778
target_link_options(${EXE_NAME} PRIVATE "/DYNAMICBASE:NO")
78-
if(BITNESS EQUAL 64)
79-
target_link_options(${EXE_NAME} PRIVATE "/HIGHENTROPYVA:NO")
80-
endif()
8179
elseif(IS_MINGW)
82-
if(BITNESS EQUAL 32)
83-
target_link_options(${EXE_NAME} PRIVATE "-Wl,--disable-dynamicbase")
84-
else()
85-
target_link_options(${EXE_NAME} PRIVATE "-Wl,--disable-dynamicbase,--disable-high-entropy-va")
86-
endif()
80+
target_link_options(${EXE_NAME} PRIVATE "-Wl,--disable-dynamicbase")
8781
endif()
8882

8983
if(IS_MINGW)

plugins/VstBase/RemoteVstPlugin32.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ ELSEIF(LMMS_BUILD_LINUX)
3434
CMAKE_ARGS
3535
"${EXTERNALPROJECT_CMAKE_ARGS}"
3636
"-DCMAKE_CXX_COMPILER=${WINEGCC}"
37-
"-DCMAKE_CXX_FLAGS=-m32"
37+
# Pass /DYNAMICBASE:NO to custom winebuild per #7987
38+
"-DCMAKE_CXX_FLAGS=-m32 --winebuild \"${CUSTOM_WINEBUILD_EXECUTABLE}\" -Wb,--disable-dynamicbase"
39+
DEPENDS wine
3840
)
3941

4042
INSTALL(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/../32/RemoteVstPlugin32" "${CMAKE_CURRENT_BINARY_DIR}/../32/RemoteVstPlugin32.exe.so" DESTINATION "${PLUGIN_DIR}/32")

plugins/VstBase/RemoteVstPlugin64.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ ELSEIF(LMMS_BUILD_LINUX)
99
CMAKE_ARGS
1010
"${EXTERNALPROJECT_CMAKE_ARGS}"
1111
"-DCMAKE_CXX_COMPILER=${WINEGCC}"
12-
"-DCMAKE_CXX_FLAGS=${CXX_FLAGS}"
12+
# Pass /DYNAMICBASE:NO to custom winebuild per #7987
13+
"-DCMAKE_CXX_FLAGS=${CXX_FLAGS} --winebuild \"${CUSTOM_WINEBUILD_EXECUTABLE}\" -Wb,--disable-dynamicbase"
14+
DEPENDS wine
1315
)
1416
INSTALL(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/../RemoteVstPlugin64" "${CMAKE_CURRENT_BINARY_DIR}/../RemoteVstPlugin64.exe.so" DESTINATION "${PLUGIN_DIR}")
1517
ENDIF()

0 commit comments

Comments
 (0)