intel: hide library symbols by default
cover intel: hide library symbols by default
Rely on -fvisibility=hidden to hide the symbols. This only applies to drm_intel.so sice there's no point in extending this if it receives a nack for some reason. For the same reason, only done on meson as well.
drm_private can also be removed from other symbols. If this passes a smoke test I'll add a patch on v2 doing so.
From git log archeology and mention in another thread we used to pass -fvisibility=hidden, but reverted to the contrary due to bug in obscure toolchain some years ago (see 0f8da82500ec542e269092c0718479e25eaff5f6). I think it's time to revisit that decision: we have plenty of other projects doing that nowadays without problem.
Lucas De Marchi (2):
intel: annotate public functions
meson: intel: make symbols hidden by default
intel/intel_bufmgr.c | 64 +++++++++++++++++----------------- intel/intel_bufmgr_fake.c | 10 +++--- intel/intel_bufmgr_gem.c | 73 +++++++++++++++++++-------------------- intel/intel_decode.c | 14 ++++---- intel/meson.build | 4 ++- libdrm_macros.h | 2 ++ 6 files changed, 85 insertions(+), 82 deletions(-)
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/2 intel: annotate public functions
This was done with:
while read sym; do
read f func line _ <<<$(cscope -d -L -1 $sym)
if [ ! -z "$f" ]; then
line=$((line-1))
sed -i "${line}s/^/drm_public /" $f
fidone < /tmp/a.txt
Then some corner cases were manually fixed. "a.txt" above contains the symbols collected from intel/intel-symbol-check. The idea here will be to switch the default visibility to hidden so we don't export symbols we shouldn't.
--- intel/intel_bufmgr.c | 64 +++++++++++++++++----------------- intel/intel_bufmgr_fake.c | 10 +++--- intel/intel_bufmgr_gem.c | 73 +++++++++++++++++++-------------------- intel/intel_decode.c | 14 ++++---- libdrm_macros.h | 2 ++ 5 files changed, 82 insertions(+), 81 deletions(-)
intel/intel_bufmgr.c +32 -32
@@ -45,21 +45,21 @@* Convenience functions for buffer management methods. */ -drm_intel_bo * +drm_public drm_intel_bo *drm_intel_bo_alloc (drm_intel_bufmgr *bufmgr,const char *name,unsigned long size,unsigned int alignment) {return bufmgr->bo_alloc (bufmgr, name, size, alignment); } -drm_intel_bo * +drm_public drm_intel_bo *drm_intel_bo_alloc_for_render (drm_intel_bufmgr *bufmgr,const char *name,unsigned long size,unsigned int alignment) {return bufmgr->bo_alloc_for_render (bufmgr, name, size, alignment); } -drm_intel_bo * +drm_public drm_intel_bo * drm_intel_bo_alloc_userptr(drm_intel_bufmgr *bufmgr, const char *name, void *addr, uint32_t tiling_mode,
@@ -73,7 +73,7 @@ drm_intel_bo_alloc_userptr(drm_intel_bufmgr *bufmgr,return NULL ; } -drm_intel_bo * +drm_public drm_intel_bo *drm_intel_bo_alloc_tiled (drm_intel_bufmgr *bufmgr,const char *name,int x,int y,int cpp,uint32_t *tiling_mode,unsigned long *pitch,unsigned long flags)
@@ -82,13 +82,13 @@ drm_intel_bo_alloc_tiled(drm_intel_bufmgr *bufmgr, const char *name, tiling_mode, pitch, flags); } -void +drm_public voiddrm_intel_bo_reference (drm_intel_bo *bo) { bo->bufmgr->bo_reference (bo); } -void +drm_public voiddrm_intel_bo_unreference (drm_intel_bo *bo) {if (bo ==NULL )
@@ -97,26 +97,26 @@ drm_intel_bo_unreference(drm_intel_bo *bo) bo->bufmgr->bo_unreference (bo); } -int +drm_public intdrm_intel_bo_map (drm_intel_bo *buf,int write_enable) {return buf->bufmgr->bo_map (buf, write_enable); } -int +drm_public intdrm_intel_bo_unmap (drm_intel_bo *buf) {return buf->bufmgr->bo_unmap (buf); } -int +drm_public intdrm_intel_bo_subdata (drm_intel_bo *bo,unsigned long offset,unsigned long size,const void *data) {return bo->bufmgr->bo_subdata (bo, offset, size, data); } -int +drm_public intdrm_intel_bo_get_subdata (drm_intel_bo *bo,unsigned long offset,unsigned long size,void *data) {
@@ -135,26 +135,26 @@ drm_intel_bo_get_subdata(drm_intel_bo *bo, unsigned long offset,return 0 ; } -void +drm_public voiddrm_intel_bo_wait_rendering (drm_intel_bo *bo) { bo->bufmgr->bo_wait_rendering (bo); } -void +drm_public voiddrm_intel_bufmgr_destroy (drm_intel_bufmgr *bufmgr) { bufmgr->destroy (bufmgr); } -int +drm_public intdrm_intel_bo_exec (drm_intel_bo *bo,int used,drm_clip_rect_t * cliprects,int num_cliprects,int DR4 ) {return bo->bufmgr->bo_exec (bo, used, cliprects, num_cliprects,DR4 ); } -int +drm_public intdrm_intel_bo_mrb_exec (drm_intel_bo *bo,int used,drm_clip_rect_t *cliprects,int num_cliprects,int DR4 ,unsigned int rings)
@@ -174,19 +174,19 @@ drm_intel_bo_mrb_exec(drm_intel_bo *bo, int used, } } -void +drm_public voiddrm_intel_bufmgr_set_debug (drm_intel_bufmgr *bufmgr,int enable_debug) { bufmgr->debug = enable_debug; } -int +drm_public intdrm_intel_bufmgr_check_aperture_space (drm_intel_bo ** bo_array,int count) {return bo_array[0 ]->bufmgr->check_aperture_space (bo_array, count); } -int +drm_public intdrm_intel_bo_flink (drm_intel_bo *bo,uint32_t * name) {if (bo->bufmgr->bo_flink)
@@ -195,7 +195,7 @@ drm_intel_bo_flink(drm_intel_bo *bo, uint32_t * name)return -ENODEV ; } -int +drm_public intdrm_intel_bo_emit_reloc (drm_intel_bo *bo,uint32_t offset,drm_intel_bo *target_bo,uint32_t target_offset,uint32_t read_domains,uint32_t write_domain)
@@ -206,7 +206,7 @@ drm_intel_bo_emit_reloc(drm_intel_bo *bo, uint32_t offset, }/* For fence registers, not GL fences */ -int +drm_public intdrm_intel_bo_emit_reloc_fence (drm_intel_bo *bo,uint32_t offset,drm_intel_bo *target_bo,uint32_t target_offset,uint32_t read_domains,uint32_t write_domain)
@@ -217,7 +217,7 @@ drm_intel_bo_emit_reloc_fence(drm_intel_bo *bo, uint32_t offset, } -int +drm_public intdrm_intel_bo_pin (drm_intel_bo *bo,uint32_t alignment) {if (bo->bufmgr->bo_pin)
@@ -226,7 +226,7 @@ drm_intel_bo_pin(drm_intel_bo *bo, uint32_t alignment)return -ENODEV ; } -int +drm_public intdrm_intel_bo_unpin (drm_intel_bo *bo) {if (bo->bufmgr->bo_unpin)
@@ -235,7 +235,7 @@ drm_intel_bo_unpin(drm_intel_bo *bo)return -ENODEV ; } -int +drm_public intdrm_intel_bo_set_tiling (drm_intel_bo *bo,uint32_t * tiling_mode,uint32_t stride) {
@@ -246,7 +246,7 @@ drm_intel_bo_set_tiling(drm_intel_bo *bo, uint32_t * tiling_mode,return 0 ; } -int +drm_public intdrm_intel_bo_get_tiling (drm_intel_bo *bo,uint32_t * tiling_mode,uint32_t * swizzle_mode) {
@@ -258,7 +258,7 @@ drm_intel_bo_get_tiling(drm_intel_bo *bo, uint32_t * tiling_mode,return 0 ; } -int +drm_public intdrm_intel_bo_set_softpin_offset (drm_intel_bo *bo,uint64_t offset) {if (bo->bufmgr->bo_set_softpin_offset)
@@ -267,7 +267,7 @@ drm_intel_bo_set_softpin_offset(drm_intel_bo *bo, uint64_t offset)return -ENODEV ; } -int +drm_public intdrm_intel_bo_disable_reuse (drm_intel_bo *bo) {if (bo->bufmgr->bo_disable_reuse)
@@ -275,7 +275,7 @@ drm_intel_bo_disable_reuse(drm_intel_bo *bo)return 0 ; } -int +drm_public intdrm_intel_bo_is_reusable (drm_intel_bo *bo) {if (bo->bufmgr->bo_is_reusable)
@@ -283,7 +283,7 @@ drm_intel_bo_is_reusable(drm_intel_bo *bo)return 0 ; } -int +drm_public intdrm_intel_bo_busy (drm_intel_bo *bo) {if (bo->bufmgr->bo_busy)
@@ -291,7 +291,7 @@ drm_intel_bo_busy(drm_intel_bo *bo)return 0 ; } -int +drm_public intdrm_intel_bo_madvise (drm_intel_bo *bo,int madv) {if (bo->bufmgr->bo_madvise)
@@ -299,7 +299,7 @@ drm_intel_bo_madvise(drm_intel_bo *bo, int madv)return -1 ; } -int +drm_public intdrm_intel_bo_use_48b_address_range (drm_intel_bo *bo,uint32_t enable) {if (bo->bufmgr->bo_use_48b_address_range) {
@@ -310,13 +310,13 @@ drm_intel_bo_use_48b_address_range(drm_intel_bo *bo, uint32_t enable)return -ENODEV ; } -int +drm_public intdrm_intel_bo_references (drm_intel_bo *bo,drm_intel_bo *target_bo) {return bo->bufmgr->bo_references (bo, target_bo); } -int +drm_public intdrm_intel_get_pipe_from_crtc_id (drm_intel_bufmgr *bufmgr,int crtc_id) {if (bufmgr->get_pipe_from_crtc_id)
@@ -360,7 +360,7 @@ drm_intel_probe_agp_aperture_size(int fd) }#endif -int +drm_public intdrm_intel_get_aperture_sizes (int fd,size_t *mappable,size_t *total) {
intel/intel_bufmgr_fake.c +5 -5
@@ -764,7 +764,7 @@ drm_intel_fake_bo_wait_rendering(drm_intel_bo *bo)* -- just evict everything * -- and wait for idle */ -void +drm_public voiddrm_intel_bufmgr_fake_contended_lock_take (drm_intel_bufmgr *bufmgr) {drm_intel_bufmgr_fake *bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr;
@@ -860,7 +860,7 @@ drm_intel_fake_bo_alloc_tiled(drm_intel_bufmgr * bufmgr, 4096); } -drm_intel_bo * +drm_public drm_intel_bo * drm_intel_bo_fake_alloc_static(drm_intel_bufmgr *bufmgr, const char *name, unsigned long offset,
@@ -1532,7 +1532,7 @@ drm_intel_fake_check_aperture_space(drm_intel_bo ** bo_array, int count)* Used by the X Server on LeaveVT, when the card memory is no longer our * own. */ -void +drm_public voiddrm_intel_bufmgr_fake_evict_all (drm_intel_bufmgr *bufmgr) {drm_intel_bufmgr_fake *bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr;
@@ -1567,7 +1567,7 @@ drm_intel_bufmgr_fake_evict_all(drm_intel_bufmgr *bufmgr)pthread_mutex_unlock (&bufmgr_fake->lock); } -void +drm_public voiddrm_intel_bufmgr_fake_set_last_dispatch (drm_intel_bufmgr *bufmgr,volatile unsigned int *last_dispatch)
@@ -1577,7 +1577,7 @@ drm_intel_bufmgr_fake_set_last_dispatch(drm_intel_bufmgr *bufmgr, bufmgr_fake->last_dispatch = (volatile int *)last_dispatch; } -drm_intel_bufmgr * +drm_public drm_intel_bufmgr *drm_intel_bufmgr_fake_init (int fd,unsigned long low_offset,void *low_virtual,unsigned long size,volatile unsigned int *last_dispatch)
intel/intel_bufmgr_gem.c +36 -37
289 lines not on this page · raw message
intel/intel_decode.c +7 -7
@@ -3811,7 +3811,7 @@ decode_3d_i830(struct drm_intel_decode *ctx)return 1 ; } -struct drm_intel_decode * +drm_public struct drm_intel_decode *drm_intel_decode_context_alloc (uint32_t devid) {struct drm_intel_decode *ctx;
@@ -3845,20 +3845,20 @@ drm_intel_decode_context_alloc(uint32_t devid)return ctx; } -void +drm_public voiddrm_intel_decode_context_free (struct drm_intel_decode *ctx) {free (ctx); } -void +drm_public voiddrm_intel_decode_set_dump_past_end (struct drm_intel_decode *ctx,int dump_past_end) { ctx->dump_past_end = !!dump_past_end; } -void +drm_public voiddrm_intel_decode_set_batch_pointer (struct drm_intel_decode *ctx,void *data,uint32_t hw_offset,int count) {
@@ -3867,7 +3867,7 @@ drm_intel_decode_set_batch_pointer(struct drm_intel_decode *ctx, ctx->base_count = count; } -void +drm_public voiddrm_intel_decode_set_head_tail (struct drm_intel_decode *ctx,uint32_t head,uint32_t tail) {
@@ -3875,7 +3875,7 @@ drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx, ctx->tail = tail; } -void +drm_public voiddrm_intel_decode_set_output_file (struct drm_intel_decode *ctx,FILE *output) {
@@ -3889,7 +3889,7 @@ drm_intel_decode_set_output_file(struct drm_intel_decode *ctx,* \param count number of DWORDs to decode in the batch buffer * \param hw_offset hardware address for the buffer */ -void +drm_public voiddrm_intel_decode (struct drm_intel_decode *ctx) {int ret;
libdrm_macros.h +2 -0
@@ -25,8 +25,10 @@#if HAVE_VISIBILITY # define drm_private __attribute__((visibility("hidden"))) +# define drm_public __attribute__((visibility("default")))#else # define drm_private +# define drm_public#endif
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/2 meson: intel: make symbols hidden by default
In reply to Lucas De Marchi--- intel/meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
intel/meson.build +3 -1
@@ -18,6 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +hidden_symbols = ['-fvisibility=hidden'] + libdrm_intel = shared_library( 'drm_intel', [
@@ -30,7 +32,7 @@ libdrm_intel = shared_library( include_directories : [inc_root, inc_drm], link_with : libdrm, dependencies : [dep_pciaccess, dep_pthread_stubs, dep_rt, dep_valgrind, dep_atomic_ops], - c_args : warn_c_args, + c_args : warn_c_args + hidden_symbols, version : '1.0.0', install : true, )
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 6 lines · Lucas De Marchi
Rely on -fvisibility=hidden to hide the symbols. This only applies to drm_intel.so sice there's no point in extending this if it receives a nack for some reason. For the same reason, only done on meson as well.
drm_privatecan also be removed from other symbols. If this passes a smoke test I'll add a patch on v2 doing so.
Series is
but yeah, without that 3rd patch to remove drm_private it isn't all that useful :P
Do you plan on converting the rest of libdrm if/when this gets accepted? It looks like you already got all the scripts ready to go ;)
Quoted 11 lines
From git log archeology and mention in another thread we used to pass -fvisibility=hidden, but reverted to the contrary due to bug in obscure toolchain some years ago (see
0f8da82500ec542e269092c0718479e25eaff5f6). I think it's time to revisit that decision: we have plenty of other projects doing that nowadays without problem.Lucas De Marchi (2):
intel: annotate public functions
meson: intel: make symbols hidden by default
Quoted 11 lines
intel/intel_bufmgr.c | 64 +++++++++++++++++----------------- intel/intel_bufmgr_fake.c | 10 +++--- intel/intel_bufmgr_gem.c | 73 +++++++++++++++++++-------------------- intel/intel_decode.c | 14 ++++---- intel/meson.build | 4 ++- libdrm_macros.h | 2 ++ 6 files changed, 85 insertions(+), 82 deletions(-)Signature · 1 line
2.17.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines · Lucas De Marchi
Quoted 8 lines · Eric Engestrom
Quoted 6 lines · Lucas De Marchi
Rely on -fvisibility=hidden to hide the symbols. This only applies to drm_intel.so sice there's no point in extending this if it receives a nack for some reason. For the same reason, only done on meson as well.
drm_privatecan also be removed from other symbols. If this passes a smoke test I'll add a patch on v2 doing so.
Quoted 8 lines
Quoted 5 lines
Series is
Reviewed-by Eric Engestrom <[email protected]>but yeah, without that 3rd patch to remove
drm_privateit isn't all that useful :PIt actually is. It already closes the door for leaking internal symbols. the
drm_internalbecomes a nop to be removed. I will include it in v2.
Ha, you're right, my bad :)
You could land it as it then, and remove drm_private in a follow up patch.
Quoted 9 lines
Quoted 4 lines
Do you plan on converting the rest of libdrm if/when this gets accepted? It looks like you already got all the scripts ready to go ;)
I will take a look on including them for v2 already. I just wish I remembered how to use coccinelle for source code transformation like this. The commands above work ok, but there's some manual work to adapt for things like "int\nfoo() { }" vs "int
foo(){ }".
Thanks!
Quoted 26 lines
Lucas De Marchi
Quoted 23 lines
Quoted 23 lines
From git log archeology and mention in another thread we used to pass
-fvisibility=hidden, but reverted to the contrary due to bug in obscure toolchain some years ago (see0f8da82500ec542e269092c0718479e25eaff5f6). I think it's time to revisit that decision: we have plenty of other projects doing that nowadays without problem.Lucas De Marchi (2):
intel: annotate public functions
meson: intel: make symbols hidden by defaultintel/intel_bufmgr.c | 64 +++++++++++++++++----------------- intel/intel_bufmgr_fake.c | 10 +++--- intel/intel_bufmgr_gem.c | 73 +++++++++++++++++++-------------------- intel/intel_decode.c | 14 ++++---- intel/meson.build | 4 ++- libdrm_macros.h | 2 ++ 6 files changed, 85 insertions(+), 82 deletions(-)Signature · 1 line
2.17.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 13 lines · Eric Engestrom
Quoted 12 lines · Lucas De Marchi
Quoted 11 lines · Eric Engestrom
Quoted 6 lines · Lucas De Marchi
Rely on -fvisibility=hidden to hide the symbols. This only applies to drm_intel.so sice there's no point in extending this if it receives a nack for some reason. For the same reason, only done on meson as well.
drm_privatecan also be removed from other symbols. If this passes a smoke test I'll add a patch on v2 doing so.Series is
Reviewed-by Eric Engestrom <[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
but yeah, without that 3rd patch to remove
drm_privateit isn't all that useful :PIt actually is. It already closes the door for leaking internal symbols. the
drm_internalbecomes a nop to be removed. I will include it in v2.Ha, you're right, my bad :)
You could land it as it then, and removedrm_privatein a follow up patch.
Also: remember that before removing drm_private, you'll need to change all the build systems to -fvisibility=hidden.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Do you plan on converting the rest of libdrm if/when this gets accepted? It looks like you already got all the scripts ready to go ;)
Quoted 33 lines
Quoted 4 lines
I will take a look on including them for v2 already. I just wish I remembered how to use coccinelle for source code transformation like this. The commands above work ok, but there's some manual work to adapt for things like "int\nfoo() { }" vs "int
foo(){ }".Thanks!
Quoted 26 lines
Lucas De Marchi
Quoted 23 lines
Quoted 23 lines
From git log archeology and mention in another thread we used to pass
-fvisibility=hidden, but reverted to the contrary due to bug in obscure toolchain some years ago (see0f8da82500ec542e269092c0718479e25eaff5f6). I think it's time to revisit that decision: we have plenty of other projects doing that nowadays without problem.Lucas De Marchi (2):
intel: annotate public functions
meson: intel: make symbols hidden by defaultintel/intel_bufmgr.c | 64 +++++++++++++++++----------------- intel/intel_bufmgr_fake.c | 10 +++--- intel/intel_bufmgr_gem.c | 73 +++++++++++++++++++-------------------- intel/intel_decode.c | 14 ++++---- intel/meson.build | 4 ++- libdrm_macros.h | 2 ++ 6 files changed, 85 insertions(+), 82 deletions(-)Signature · 1 line
2.17.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel