Skip to content

Commit

Permalink
Merge pull request #178 from bgilbert/java
Browse files Browse the repository at this point in the history
Update OpenSlide Java and fix it on Linux/macOS
  • Loading branch information
bgilbert authored Nov 8, 2023
2 parents 333fd55 + 3975116 commit e1b6b90
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 10 deletions.
6 changes: 3 additions & 3 deletions meson/cross-macos-arm64.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[built-in options]
prefix = '/'
c_args = ['-O2', '-g', '-fstack-protector-strong', '--target=aarch64-apple-macosx11']
c_link_args = ['--target=aarch64-apple-macosx11', '-Wl,-exported_symbol,_openslide_*']
c_link_args = ['--target=aarch64-apple-macosx11']
cpp_args = ['-O2', '-g', '-fstack-protector-strong', '--target=aarch64-apple-macosx11']
cpp_link_args = ['--target=aarch64-apple-macosx11', '-Wl,-exported_symbol,_openslide_*']
cpp_link_args = ['--target=aarch64-apple-macosx11']
objc_args = ['-O2', '-g', '-fstack-protector-strong', '--target=aarch64-apple-macosx11']
objc_link_args = ['--target=aarch64-apple-macosx11', '-Wl,-exported_symbol,_openslide_*']
objc_link_args = ['--target=aarch64-apple-macosx11']
pkg_config_path = ''

[properties]
Expand Down
6 changes: 3 additions & 3 deletions meson/cross-macos-x86_64.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[built-in options]
prefix = '/'
c_args = ['-O2', '-g', '-fstack-protector-strong', '--target=x86_64-apple-macosx11']
c_link_args = ['--target=x86_64-apple-macosx11', '-Wl,-exported_symbol,_openslide_*']
c_link_args = ['--target=x86_64-apple-macosx11']
cpp_args = ['-O2', '-g', '-fstack-protector-strong', '--target=x86_64-apple-macosx11']
cpp_link_args = ['--target=x86_64-apple-macosx11', '-Wl,-exported_symbol,_openslide_*']
cpp_link_args = ['--target=x86_64-apple-macosx11']
objc_args = ['-O2', '-g', '-fstack-protector-strong', '--target=x86_64-apple-macosx11']
objc_link_args = ['--target=x86_64-apple-macosx11', '-Wl,-exported_symbol,_openslide_*']
objc_link_args = ['--target=x86_64-apple-macosx11']
pkg_config_path = ''

[properties]
Expand Down
2 changes: 2 additions & 0 deletions meson/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,15 @@ subproject(
# We don't run tests, but we still check that they build
'default_library=shared',
'doc=disabled',
'_filter_external_symbols=true',
'version_suffix=' + get_option('version_suffix'),
'werror=' + get_option('openslide_werror').to_string(),
],
)
subproject(
'openslide-java',
default_options : [
'embed_jni_path=disabled',
'werror=' + get_option('openslide_werror').to_string(),
],
)
8 changes: 4 additions & 4 deletions meson/subprojects/openslide-java.wrap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# not from wrapdb

[wrap-file]
directory = openslide-java-0.12.3
source_url = https://github.com/openslide/openslide-java/releases/download/v0.12.3/openslide-java-0.12.3.tar.xz
source_filename = openslide-java-0.12.3.tar.xz
source_hash = 0fb4ef9aac3cc5f60e685ddd8886ba75d195f8f7bc61c8bd26e0eaa919f0c90e
directory = openslide-java-0.12.4
source_url = https://github.com/openslide/openslide-java/releases/download/v0.12.4/openslide-java-0.12.4.tar.xz
source_filename = openslide-java-0.12.4.tar.xz
source_hash = 63a6cd63fedc7c700020708c0a362b3807b6780f0246b12c8dc372cecd6130cf
3 changes: 3 additions & 0 deletions meson/subprojects/openslide.wrap
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ directory = openslide-4.0.0
source_url = https://github.com/openslide/openslide/releases/download/v4.0.0/openslide-4.0.0.tar.xz
source_filename = openslide-4.0.0.tar.xz
source_hash = cc227c44316abb65fb28f1c967706eb7254f91dbfab31e9ae6a48db6cf4ae562

# https://github.com/openslide/openslide/pull/535
diff_files = openslide-symbols.patch
72 changes: 72 additions & 0 deletions meson/subprojects/packagefiles/openslide-symbols.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
From 8ffb2c233432024c7adb24a1f7a0b25b28112014 Mon Sep 17 00:00:00 2001
From: Benjamin Gilbert <[email protected]>
Date: Tue, 7 Nov 2023 10:55:08 -0600
Subject: [PATCH] meson: add a private option to filter out non-OpenSlide
symbols

On macOS, openslide-bin needs to use a linker option to filter out
non-OpenSlide exported symbols. It can't set the option globally because
that would break OpenSlide Java, and can't set a per-project option
because Meson doesn't support that. Add a private option to do the
filtering until Meson provides syntax for this.

Signed-off-by: Benjamin Gilbert <[email protected]>
---
meson.build | 10 ++++++++++
meson_options.txt | 6 ++++++
src/meson.build | 1 +
3 files changed, 17 insertions(+)

diff --git a/meson.build b/meson.build
index 0b4d7d47b695..852b976419a9 100644
--- a/meson.build
+++ b/meson.build
@@ -161,6 +161,16 @@ endif

# Test suite options
visibility = get_option('_export_internal_symbols') ? '' : 'hidden'
+libopenslide_link_args = (
+ # On macOS, openslide-bin needs to keep non-OpenSlide symbols out of the
+ # combined dylib, but it can't do it via global link options without
+ # breaking the exports of the OpenSlide Java JNI library. Until Meson
+ # allows passing compiler flags to individual subprojects, provide a
+ # workaround here.
+ # https://github.com/mesonbuild/meson/issues/11002
+ get_option('_filter_external_symbols') and host_machine.system() == 'darwin'
+ ? ['-Wl,-exported_symbol,_openslide_*'] : []
+)
if get_option('_gcov')
add_project_arguments(
'-O0',
diff --git a/meson_options.txt b/meson_options.txt
index 1a71bf92c235..a11494c85f7a 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -29,6 +29,12 @@ option(
value : false,
description : 'For test suite; do not use',
)
+option(
+ '_filter_external_symbols',
+ type : 'boolean',
+ value : false,
+ description : 'For openslide-bin; do not use',
+)
option(
'_gcov',
type : 'boolean',
diff --git a/src/meson.build b/src/meson.build
index f9d184be1bc7..e8997cae00ed 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -78,6 +78,7 @@ libopenslide = library('openslide',
openslide_sources,
version : soversion,
c_args : ['-D_OPENSLIDE_BUILDING_DLL', '-DG_LOG_DOMAIN="OpenSlide"'],
+ link_args : libopenslide_link_args,
gnu_symbol_visibility : visibility,
include_directories : config_h_include,
dependencies : [
--
2.41.0

0 comments on commit e1b6b90

Please sign in to comment.