summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile11
-rw-r--r--lib/assembly.h7
-rw-r--r--make/lib_info.mk3
-rw-r--r--make/options.mk8
-rw-r--r--make/platform/darwin_bni.mk1
-rw-r--r--make/platform/darwin_fat.mk2
-rw-r--r--make/platform/multi_arch.mk2
7 files changed, 27 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 5a6f01745..79149e325 100644
--- a/Makefile
+++ b/Makefile
@@ -205,19 +205,20 @@ $(call Set,Tmp.Dependencies,$($(Tmp.SubDirKey).Dependencies))
$(call Set,Tmp.CC,$(strip \
$(call GetCNAVar,CC,$(Tmp.Key),$(Tmp.Config),$(Tmp.Arch))))
$(call Set,Tmp.CFLAGS,$(strip \
+ $(if $(call IsDefined,$(Tmp.Key).UniversalArchs),-arch $(Tmp.Arch),)\
+ $(if $(call streq,$($(Tmp.Key).VISIBILITY_HIDDEN),1),\
+ -fvisibility=hidden -DVISIBILITY_HIDDEN,)\
$(call GetCNAVar,CFLAGS,$(Tmp.Key),$(Tmp.Config),$(Tmp.Arch))))
-$(call Set,Tmp.ArchFlag,$(strip \
- $(if $(call IsDefined,$(Tmp.Key).UniversalArchs),-arch $(Tmp.Arch),)))
$(Tmp.ObjPath)/%.o: $(Tmp.SrcPath)/%.s $(Tmp.Dependencies) $(Tmp.ObjPath)/.dir
$(Summary) " ASSEMBLE: $(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch): $$<"
- $(Verb) $(Tmp.CC) $(Tmp.ArchFlag) $(Tmp.CFLAGS) -c -o $$@ $$<
+ $(Verb) $(Tmp.CC) $(Tmp.CFLAGS) -c -o $$@ $$<
$(Tmp.ObjPath)/%.o: $(Tmp.SrcPath)/%.S $(Tmp.Dependencies) $(Tmp.ObjPath)/.dir
$(Summary) " ASSEMBLE: $(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch): $$<"
- $(Verb) $(Tmp.CC) $(Tmp.ArchFlag) $(Tmp.CFLAGS) -c -o $$@ $$<
+ $(Verb) $(Tmp.CC) $(Tmp.CFLAGS) -c -o $$@ $$<
$(Tmp.ObjPath)/%.o: $(Tmp.SrcPath)/%.c $(Tmp.Dependencies) $(Tmp.ObjPath)/.dir
$(Summary) " COMPILE: $(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch): $$<"
- $(Verb) $(Tmp.CC) $(Tmp.ArchFlag) $(Tmp.CFLAGS) -c -o $$@ $$<
+ $(Verb) $(Tmp.CC) $(Tmp.CFLAGS) -c -o $$@ $$<
.PRECIOUS: $(Tmp.ObjPath)/.dir
endef
diff --git a/lib/assembly.h b/lib/assembly.h
index e6b84108f..c2d5a34ff 100644
--- a/lib/assembly.h
+++ b/lib/assembly.h
@@ -30,9 +30,16 @@
#define SYMBOL_NAME(name) name
#endif
+#ifdef VISIBILITY_HIDDEN
+#define DEFINE_COMPILERRT_FUNCTION(name) \
+ .globl SYMBOL_NAME(name) SEPARATOR \
+ .private_extern SYMBOL_NAME(name) SEPARATOR \
+ SYMBOL_NAME(name):
+#else
#define DEFINE_COMPILERRT_FUNCTION(name) \
.globl SYMBOL_NAME(name) SEPARATOR \
SYMBOL_NAME(name):
+#endif
#define DEFINE_COMPILERRT_PRIVATE_FUNCTION(name) \
.globl SYMBOL_NAME(name) SEPARATOR \
diff --git a/make/lib_info.mk b/make/lib_info.mk
index 91ee23b55..a54152a4f 100644
--- a/make/lib_info.mk
+++ b/make/lib_info.mk
@@ -46,4 +46,5 @@ $(foreach key,$(SubDirKeys),\
# The names of all the available options.
AvailableOptions := AR ARFLAGS \
CC CFLAGS FUNCTIONS OPTIMIZED \
- RANLIB RANLIBFLAGS
+ RANLIB RANLIBFLAGS \
+ VISIBILITY_HIDDEN
diff --git a/make/options.mk b/make/options.mk
index 392bbdde5..f6a331bf0 100644
--- a/make/options.mk
+++ b/make/options.mk
@@ -15,6 +15,14 @@ FUNCTIONS :=
# Whether optimized function implementations should be used.
OPTIMIZED := 1
+# Whether function definitions should use hidden visibility. This adds the
+# -fvisibility=hidden compiler option and uses .private_extern annotations in
+# assembly files.
+#
+# FIXME: Make this more portable. When that is done, it should probably be the
+# default.
+VISIBILITY_HIDDEN := 0
+
# Miscellaneous tools.
AR := ar
diff --git a/make/platform/darwin_bni.mk b/make/platform/darwin_bni.mk
index 952b10474..e713d243d 100644
--- a/make/platform/darwin_bni.mk
+++ b/make/platform/darwin_bni.mk
@@ -50,3 +50,4 @@ FUNCTIONS.armv6 := $(FUNCTIONS) \
subdf3vfp subsf3vfp truncdfsf2vfp unorddf2vfp unordsf2vfp \
modsi3 umodsi3 udivsi3 divsi3 switch save_restore_d8_d15
+VISIBILITY_HIDDEN := 0
diff --git a/make/platform/darwin_fat.mk b/make/platform/darwin_fat.mk
index cea2a51f2..3659e041f 100644
--- a/make/platform/darwin_fat.mk
+++ b/make/platform/darwin_fat.mk
@@ -51,3 +51,5 @@ FUNCTIONS.armv6 := $(CommonFunctions) $(ArchFunctions.armv6)
FUNCTIONS.armv7 := $(CommonFunctions) $(ArchFunctions.armv7)
OPTIMIZED.Debug := 0
+
+VISIBILITY_HIDDEN := 1
diff --git a/make/platform/multi_arch.mk b/make/platform/multi_arch.mk
index c85f3d904..eebc7b2f8 100644
--- a/make/platform/multi_arch.mk
+++ b/make/platform/multi_arch.mk
@@ -13,4 +13,4 @@ CFLAGS.m32 := $(CFLAGS) -m32 -O3
CFLAGS.m64 := $(CFLAGS) -m64 -O3
FUNCTIONS := moddi3 floatundixf udivdi3
-FUNCTIONS.m64 := $(FUNCTIONS) lshrdi3 \ No newline at end of file
+FUNCTIONS.m64 := $(FUNCTIONS) lshrdi3