1
0
mirror of https://github.com/janet-lang/janet synced 2025-01-12 00:20:26 +00:00

Add -fvisibility in Makefile, provide meson example commands.

Shaves off 10 kb in binary. Also -fpic -> -fPIC in Makefile and jpm.
This commit is contained in:
Calvin Rose 2019-10-05 10:38:58 -05:00
parent e9f3dc7d5c
commit 6ae5a9be60
4 changed files with 38 additions and 2 deletions

View File

@ -37,7 +37,7 @@ MANPATH?=$(PREFIX)/share/man/man1/
PKG_CONFIG_PATH?=$(LIBDIR)/pkgconfig
DEBUGGER=gdb
CFLAGS=-std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fpic -O2 -fvisibility=hidden \
CFLAGS=-std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fPIC -O2 -fvisibility=hidden \
-DJANET_BUILD=$(JANET_BUILD)
LDFLAGS=-rdynamic

View File

@ -132,6 +132,25 @@ is maybe more convenient and flexible for integrating into existing pipelines.
Meson also provides much better IDE integration than Make or batch files, as well as support
for cross compilation.
For the impatient, building with Meson is as simple as follows. The options provided to
`meson setup` below emulate Janet's Makefile.
```sh
git clone https://github.com/janet-lang/janet.git
cd janet
meson setup build \
--buildtype release \
--optimization 2 \
-Dgit_hash=$(git log --pretty=format:'%h' -n 1)
ninja -C build
# Run the binary
build/janet
# Installation
ninja -C build install
```
## Development
Janet can be hacked on with pretty much any environment you like, but for IDE

View File

@ -124,7 +124,7 @@
(def- dynamic-cflags
(if is-win
[]
["-fpic"]))
["-fPIC"]))
(def- dynamic-lflags
(if is-win
["/DLL"]

View File

@ -170,15 +170,32 @@ libjanet = library('janet', core_src, core_image,
dependencies : [m_dep, dl_dep],
install : true)
# Extra c flags - adding -fvisibility=hidden matches the Makefile and
# shaves off about 10k on linux x64, likely similar on other platforms.
native_cc = meson.get_compiler('c', native: true)
cross_cc = meson.get_compiler('c', native: false)
if native_cc.has_argument('-fvisibility=hidden')
extra_native_cflags = ['-fvisibility=hidden']
else
extra_native_cflags = []
endif
if cross_cc.has_argument('-fvisibility=hidden')
extra_cross_cflags = ['-fvisibility=hidden']
else
extra_cross_cflags = []
endif
janet_mainclient = executable('janet', core_src, core_image, init_gen, mainclient_src,
include_directories : incdir,
dependencies : [m_dep, dl_dep],
c_args : extra_native_cflags,
install : true)
if meson.is_cross_build()
janet_nativeclient = executable('janet-native', core_src, core_image, init_gen, mainclient_src,
include_directories : incdir,
dependencies : [m_dep, dl_dep],
c_args : extra_cross_cflags,
native : true)
else
janet_nativeclient = janet_mainclient