diff --git a/Makefile b/Makefile index 59554e1d..5339d1e6 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,8 @@ endif OBJ := $(SRC:.c=.o) # define default flags, and override to append mandatory flags -CFLAGS ?= -O3 -Wall -Wextra -Werror -Wshadow -override CFLAGS += -std=gnu99 -fPIC -Ilib/src -Ilib/include +override CFLAGS := -O3 -std=gnu99 -fPIC -fvisibility=hidden -Wall -Wextra -Werror -Wshadow $(CFLAGS) +override CFLAGS += -Ilib/src -Ilib/include # ABI versioning SONAME_MAJOR := 0 @@ -50,6 +50,9 @@ libtree-sitter.$(SOEXTVER): $(OBJ) $(CC) $(LDFLAGS) $(LINKSHARED) $^ $(LDLIBS) -o $@ ln -sf $@ libtree-sitter.$(SOEXT) ln -sf $@ libtree-sitter.$(SOEXTVER_MAJOR) +ifneq ($(STRIP),) + $(STRIP) $@ +endif install: all install -d '$(DESTDIR)$(LIBDIR)' diff --git a/lib/binding_rust/build.rs b/lib/binding_rust/build.rs index 5798cde3..c812c3b9 100644 --- a/lib/binding_rust/build.rs +++ b/lib/binding_rust/build.rs @@ -26,7 +26,9 @@ fn main() { cc::Build::new() .flag_if_supported("-std=c99") - .flag_if_supported("-Wno-unused-parameter") + .flag_if_supported("-fvisibility=hidden") + .flag_if_supported("-Wshadow") + .flag_if_supported("-Werror") .include(src_path) .include("include") .file(src_path.join("lib.c")) diff --git a/lib/include/tree_sitter/api.h b/lib/include/tree_sitter/api.h index 9e936ff8..1cc6b3e9 100644 --- a/lib/include/tree_sitter/api.h +++ b/lib/include/tree_sitter/api.h @@ -1,6 +1,8 @@ #ifndef TREE_SITTER_API_H_ #define TREE_SITTER_API_H_ +#pragma GCC visibility push(default) + #ifdef __cplusplus extern "C" { #endif @@ -1163,4 +1165,6 @@ void ts_set_allocator( } #endif +#pragma GCC visibility pop + #endif // TREE_SITTER_API_H_ diff --git a/lib/src/subtree.c b/lib/src/subtree.c index 5f39bd82..51bc2ef6 100644 --- a/lib/src/subtree.c +++ b/lib/src/subtree.c @@ -647,10 +647,10 @@ Subtree ts_subtree_edit(Subtree self, const TSInputEdit *input_edit, SubtreePool typedef struct { Subtree *tree; Edit edit; - } StackEntry; + } EditEntry; - Array(StackEntry) stack = array_new(); - array_push(&stack, ((StackEntry) { + Array(EditEntry) stack = array_new(); + array_push(&stack, ((EditEntry) { .tree = &self, .edit = (Edit) { .start = {input_edit->start_byte, input_edit->start_point}, @@ -660,7 +660,7 @@ Subtree ts_subtree_edit(Subtree self, const TSInputEdit *input_edit, SubtreePool })); while (stack.size) { - StackEntry entry = array_pop(&stack); + EditEntry entry = array_pop(&stack); Edit edit = entry.edit; bool is_noop = edit.old_end.bytes == edit.start.bytes && edit.new_end.bytes == edit.start.bytes; bool is_pure_insertion = edit.old_end.bytes == edit.start.bytes; @@ -788,7 +788,7 @@ Subtree ts_subtree_edit(Subtree self, const TSInputEdit *input_edit, SubtreePool } // Queue processing of this child's subtree. - array_push(&stack, ((StackEntry) { + array_push(&stack, ((EditEntry) { .tree = child, .edit = child_edit, }));