Skip to content

Commit

Permalink
Merge pull request #138 from topazus/fix-meson
Browse files Browse the repository at this point in the history
Set -fvisibility=hidden and -fvisibility-inlines-hidden for Meson
  • Loading branch information
cschreib authored Nov 7, 2023
2 parents 3c908fe + 89aff83 commit f605e7e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/meson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- { name: Linux GCC 12, os: ubuntu-latest, compiler: g++12, cxx: "g++-12", backend: "ninja", build: "linux-libstdc++", args: ""}
- { name: Linux GCC 12 nounity, os: ubuntu-latest, compiler: g++12, cxx: "g++-12", backend: "ninja", build: "linux-libstdc++", args: "-Dunity_build=false"}
- { name: Linux GCC 12 shared, os: ubuntu-latest, compiler: g++12, cxx: "g++-12", backend: "ninja", build: "linux-libstdc++", args: "--default-library shared"}
- { name: Linux Clang 14, os: ubuntu-latest, compiler: clang-14, cxx: "clang++-14", backend: "ninja", build: "linux-libc++", args: ""}
- { name: Linux Clang 15, os: ubuntu-latest, compiler: clang-15, cxx: "clang++-15", backend: "ninja", build: "linux-libc++", args: "-Dcpp_args='-stdlib=libc++' -Dcpp_link_args='-stdlib=libc++'"}
- { name: Windows 64, os: windows-latest, compiler: msvc, cxx: "cl", backend: "vs2022 --vsenv", build: "win64-vs2022", args: ""}
- { name: MacOS, os: macos-latest, compiler: clang++, cxx: "clang++", backend: "ninja", build: "osx-libc++", args: ""}
build-type:
Expand All @@ -32,6 +32,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Clang
if: matrix.platform.compiler == 'clang-15' && matrix.platform.os == 'ubuntu-latest'
run: sudo apt install clang-15 libc++-15-dev libc++abi-15-dev

- uses: actions/setup-python@v4
with:
python-version: '3.x'
Expand Down
22 changes: 22 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@ project('snitch', 'cpp',
version: '1.2.3'
)

cpp_arguments = []

cxx = meson.get_compiler('cpp')
compiler_id = cxx.get_id()
host_system = host_machine.system()
is_mingw = host_system == 'windows' and cxx.get_id() == 'gcc'

if get_option('default_library') == 'shared'
if compiler_id == 'msvc' or is_mingw
# Nothing to do; default is already to hide symbols unless exported.
elif compiler_id == 'gcc' or compiler_id == 'clang'
# Set default visibility to "hidden" so only exported symbols are visible.
cpp_arguments += cxx.get_supported_arguments([
'-fvisibility=hidden',
'-fvisibility-inlines-hidden'
])
endif
endif

add_project_arguments(cpp_arguments, language : 'cpp')
add_project_link_arguments(cpp_arguments, language : 'cpp')

include_dirs = include_directories('.', 'include')

headers = files('include/snitch/snitch.hpp',
Expand Down

0 comments on commit f605e7e

Please sign in to comment.