mirror of
https://github.com/janet-lang/janet
synced 2025-01-12 08:30: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:
parent
e9f3dc7d5c
commit
6ae5a9be60
2
Makefile
2
Makefile
@ -37,7 +37,7 @@ MANPATH?=$(PREFIX)/share/man/man1/
|
|||||||
PKG_CONFIG_PATH?=$(LIBDIR)/pkgconfig
|
PKG_CONFIG_PATH?=$(LIBDIR)/pkgconfig
|
||||||
DEBUGGER=gdb
|
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)
|
-DJANET_BUILD=$(JANET_BUILD)
|
||||||
LDFLAGS=-rdynamic
|
LDFLAGS=-rdynamic
|
||||||
|
|
||||||
|
19
README.md
19
README.md
@ -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
|
Meson also provides much better IDE integration than Make or batch files, as well as support
|
||||||
for cross compilation.
|
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
|
## Development
|
||||||
|
|
||||||
Janet can be hacked on with pretty much any environment you like, but for IDE
|
Janet can be hacked on with pretty much any environment you like, but for IDE
|
||||||
|
@ -124,7 +124,7 @@
|
|||||||
(def- dynamic-cflags
|
(def- dynamic-cflags
|
||||||
(if is-win
|
(if is-win
|
||||||
[]
|
[]
|
||||||
["-fpic"]))
|
["-fPIC"]))
|
||||||
(def- dynamic-lflags
|
(def- dynamic-lflags
|
||||||
(if is-win
|
(if is-win
|
||||||
["/DLL"]
|
["/DLL"]
|
||||||
|
17
meson.build
17
meson.build
@ -170,15 +170,32 @@ libjanet = library('janet', core_src, core_image,
|
|||||||
dependencies : [m_dep, dl_dep],
|
dependencies : [m_dep, dl_dep],
|
||||||
install : true)
|
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,
|
janet_mainclient = executable('janet', core_src, core_image, init_gen, mainclient_src,
|
||||||
include_directories : incdir,
|
include_directories : incdir,
|
||||||
dependencies : [m_dep, dl_dep],
|
dependencies : [m_dep, dl_dep],
|
||||||
|
c_args : extra_native_cflags,
|
||||||
install : true)
|
install : true)
|
||||||
|
|
||||||
if meson.is_cross_build()
|
if meson.is_cross_build()
|
||||||
janet_nativeclient = executable('janet-native', core_src, core_image, init_gen, mainclient_src,
|
janet_nativeclient = executable('janet-native', core_src, core_image, init_gen, mainclient_src,
|
||||||
include_directories : incdir,
|
include_directories : incdir,
|
||||||
dependencies : [m_dep, dl_dep],
|
dependencies : [m_dep, dl_dep],
|
||||||
|
c_args : extra_cross_cflags,
|
||||||
native : true)
|
native : true)
|
||||||
else
|
else
|
||||||
janet_nativeclient = janet_mainclient
|
janet_nativeclient = janet_mainclient
|
||||||
|
Loading…
Reference in New Issue
Block a user