smrender icon indicating copy to clipboard operation
smrender copied to clipboard

no symbol 'act_*' on macOS

Open sikmir opened this issue 3 months ago • 12 comments

I use basemap.osm rule and everything fine on Linux:

13:24:14.775  (+ 0.000) 0:[  debug] init_rule() initializing rule -1099511627775 (0xffffff0000000001, 1)
13:24:14.775  (+ 0.000) 0:[  debug] parsing 'cap:font=sans-serif:italic;size=1.4;angle=auto;halign=east;key=name'
13:24:14.775  (+ 0.000) 0:[  debug] calling cap_ini()[0]
13:24:14.775  (+ 0.000) 0:[  debug] parse_auto_rot() auto_rot = {phase: 0.00, autocol(deprecated): 0x00000000, weight: 1.00, mkarea: 0}
13:24:14.775  (+ 0.000) 0:[  debug] act_cap_ini() halignkey = NULL, valignkey = NULL
13:24:14.775  (+ 0.000) 0:[  debug] act_cap_ini() pos = 0x0004, col = 0x00000000, colkey = 'NULL', font = 'sans-serif:italic', key = 'name', size = 1.4, scl = {12.0, 0.5, 8.0, 0.20}, angle = nan, xoff = 2.0, yoff =2.0, rot = {0.0, 00000000, 1.0}, {fill = 0, fillcol 0x00000000, filcolkey "NULL"}, bgbox_scale = 1.20, fontbox = 0
13:24:14.775  (+ 0.000) 0:[  debug] act_cap_ini() filter[0] = 'name'

But on macOS I got:

13:23:29.850  (+ 0.000) 0:[  debug] init_rule() initializing rule -1099511627775 (0xffffff0000000001, 1)
13:23:29.850  (+ 0.000) 0:[  debug] parsing 'cap:font=sans-serif:italic;size=1.4;angle=auto;halign=east;key=name'
13:23:29.850  (+ 0.000) 0:[   info] no symbol 'act_cap_main'
13:23:29.850  (+ 0.000) 0:[   info] no symbol 'act_cap_ini'
13:23:29.850  (+ 0.000) 0:[   info] no symbol 'act_cap_fini'

And symbols exist in the binary:

nm -gU ./smrender | grep act_cap
0000000100020890 T _act_cap_fini
000000010001ea50 T _act_cap_ini
000000010001f220 T _act_cap_main

sikmir avatar Oct 04 '25 09:10 sikmir

This looks like if the symbols are prepended with an underscore. That's why they are not found. But I'm not sure why this is the case. Probably a compiler option on MacOS. Which compiler do you use?

rahra avatar Oct 04 '25 12:10 rahra

This looks like if the symbols are prepended with an underscore. That's why they are not found. But I'm not sure why this is the case. Probably a compiler option on MacOS. Which compiler do you use?

No, I've already tried to patch smrender to load symbols with "_" prefix, it doesn't help. Compiler is clang.

sikmir avatar Oct 04 '25 12:10 sikmir

I'm not sure why smrender tries to dlsym those symbols, while they are in smrender binary, not in a library loaded via dlopen?

sikmir avatar Oct 04 '25 12:10 sikmir

This looks like if the symbols are prepended with an underscore. That's why they are not found. But I'm not sure why this is the case. Probably a compiler option on MacOS. Which compiler do you use?

No, I've already tried to patch smrender to load symbols with "_" prefix, it doesn't help. Compiler is clang.

Ok, but it still may have to do something with the export options of the compiler and linker.

rahra avatar Oct 04 '25 12:10 rahra

I'm not sure why smrender tries to dlsym those symbols, while they are in smrender binary, not in a library loaded via dlopen?

This is because with this you can load symbols from external libraries as well. So the idea is that one can easily add his own functions without modifiying smrender itself.

rahra avatar Oct 04 '25 13:10 rahra

When you compile with make, can you check if there is -Wl,--export-dynamic or -Wl,-export-dynamic present in the libtool linking command line of smrender?

https://cmd.inp.nsk.su/old/cmd2/manuals/gnudocs/gnudocs/libtool/libtool_39.html https://stackoverflow.com/questions/21279036/what-is-clangs-equivalent-to-rdynamic-gcc-flag

rahra avatar Oct 04 '25 16:10 rahra

When you compile with make, can you check if there is -Wl,--export-dynamic or -Wl,-export-dynamic present in the libtool linking command line of smrender?

https://cmd.inp.nsk.su/old/cmd2/manuals/gnudocs/gnudocs/libtool/libtool_39.html https://stackoverflow.com/questions/21279036/what-is-clangs-equivalent-to-rdynamic-gcc-flag

No, there is no export-dynamic in build log.

smrender> libtool: link: clang -I/nix/store/gg6rqsiqy01qcq38qlj8wkzgdjfmmn51-cairo-1.18.4-dev/include/cairo -I/nix/store/b9wl9l40xb2m15ybmdwf2asljjxjhlyz-freet
ype-2.13.3-dev/include/freetype2 -I/nix/store/b9wl9l40xb2m15ybmdwf2asljjxjhlyz-freetype-2.13.3-dev/include -I/nix/store/gg6rqsiqy01qcq38qlj8wkzgdjfmmn51-cairo-
1.18.4-dev/include/cairo -I/nix/store/b9wl9l40xb2m15ybmdwf2asljjxjhlyz-freetype-2.13.3-dev/include/freetype2 -I/nix/store/b9wl9l40xb2m15ybmdwf2asljjxjhlyz-free
type-2.13.3-dev/include -I/nix/store/vrkl70vqhriz997764s0j1x2lis3d532-glib-2.84.4-dev/include -I/nix/store/vrkl70vqhriz997764s0j1x2lis3d532-glib-2.84.4-dev/inc
lude/glib-2.0 -I/nix/store/kmrj99qm1z8p22pxk8l2a13n28cfnxmz-glib-2.84.4/lib/glib-2.0/include -I/nix/store/0a672p53455n48h3w9gnsk6s8c2v3iwy-librsvg-2.60.0-dev/i
nclude/librsvg-2.0 -I/nix/store/7rvybw0wvqip2rp7dkaggxl9616j52r5-gdk-pixbuf-2.42.12-dev/include/gdk-pixbuf-2.0 -I/nix/store/yw12p9pqs7ssksjkc5daw25pq15fs6bm-li
bjpeg-turbo-3.1.1-dev/include -I/nix/store/vrkl70vqhriz997764s0j1x2lis3d532-glib-2.84.4-dev/include/glib-2.0 -I/nix/store/kmrj99qm1z8p22pxk8l2a13n28cfnxmz-glib
-2.84.4/lib/glib-2.0/include -g -O2 -Wall -Wextra -D_THREAD_SAFE -o .libs/smrender smath.o smfunc.o smloadosm.o smrparse.o libhpxml.o smcoast.o smgrid.o smrend
er.o smkap.o smqr.o smthread.o smtile.o smrules_cairo.o rdata.o median_cut.o smexec.o smcore.o smosmout.o bspline_ctrl.o cairo_jpg.o adams.o smjson.o smem.o us
age.o smindex.o  -L/nix/store/zhigi2z5drpb1jrhbpj6n84vwj2bjwv9-cairo-1.18.4/lib -L/nix/store/yvawd0jjpjia28ajqqapi1w84f4w8jag-fontconfig-2.16.2-lib/lib -L/nix/
store/087nb4bma3p985rapnnkq324gj8yq9ir-freetype-2.13.3/lib /nix/store/yvawd0jjpjia28ajqqapi1w84f4w8jag-fontconfig-2.16.2-lib/lib/libfontconfig.dylib /nix/store
/087nb4bma3p985rapnnkq324gj8yq9ir-freetype-2.13.3/lib/libfreetype.dylib -L/nix/store/3rr56b63qirkys6dwf3izwf2nddyr27k-zlib-1.3.1/lib -L/nix/store/cd1gr9x24ap97
j56w1z4spjnva0g9f0b-bzip2-1.0.8/lib -L/nix/store/4sycqja7q80i54r7rflmx2g86nvycxrw-libpng-apng-1.6.49/lib -L/nix/store/fjghdp4yv8m27jhs7gpzcrwf6sl3h7k5-brotli-1
.1.0-lib/lib -lz /nix/store/cd1gr9x24ap97j56w1z4spjnva0g9f0b-bzip2-1.0.8/lib/libbz2.dylib /nix/store/4sycqja7q80i54r7rflmx2g86nvycxrw-libpng-apng-1.6.49/lib/li
bpng16.dylib -lbrotlidec -lpthread -L/nix/store/kmrj99qm1z8p22pxk8l2a13n28cfnxmz-glib-2.84.4/lib -L/nix/store/h5zqfg3nc8zhjnlcj1rn9z0vrpgrhpvi-librsvg-2.60.0/l
ib -L/nix/store/1i9skdj3dabl9clzn4nc1ii90jn50rly-gdk-pixbuf-2.42.12/lib -lrsvg-2 -lgio-2.0 -lgdk_pixbuf-2.0 -lgobject-2.0 -lcairo -L/nix/store/7jxz2r29fcdvjp9l
gi3py8pdwjv6miwl-libjpeg-turbo-3.1.1/lib -ljpeg -lglib-2.0 ../libsmrender/smrender/.libs/libsmrender.dylib -pthread

sikmir avatar Oct 08 '25 23:10 sikmir

Ok. You can try to execute the command from above manually and add the export option after -Wextra.

rahra avatar Oct 10 '25 18:10 rahra

Ok. You can try to execute the command from above manually and add the export option after -Wextra.

This patch doesn't help:

diff --git i/src/Makefile.am w/src/Makefile.am
index b598a64..cf144df 100644
--- i/src/Makefile.am
+++ w/src/Makefile.am
@@ -1,4 +1,4 @@
-AM_LDFLAGS = $(EXP_DYN) $(GD_LDFLAGS) $(GD_LIBS) $(CAIRO_LIBS) $(FONTCONFIG_LIBS) $(RSVG_LIBS) $(LIBJPEG_LIBS) $(GLIB_LIBS)
+AM_LDFLAGS = $(EXP_DYN) $(GD_LDFLAGS) -Wl,-export_dynamic $(GD_LIBS) $(CAIRO_LIBS) $(FONTCONFIG_LIBS) $(RSVG_LIBS) $(LIBJPEG_LIBS) $(GLIB_LIBS)
 AM_CFLAGS = $(GD_CFLAGS) $(CAIRO_CFLAGS) $(RSVG_CFLAGS) $(LIBJPEG_CFLAGS) $(GLIB_CFLAGS)
 AM_CPPFLAGS = -I$(srcdir)/../libsmrender
 bin_PROGRAMS = smrender
smrender> libtool: link: clang -I/nix/store/3xlnbsh786818m0gi4v2b9h92lkcpzxk-cairo-1.18.4-dev/include/cairo -I/nix/store/vzmdbdwiwgkd7fqzb2l2d06vyiyapmaf-freetype-2.13.3-dev/include/freetype2 -I/nix/store/vzmdbdwiwgkd7fqzb2l2d06vyiyapmaf-freetype-2.13.3-dev/include -I/nix/store/3xlnbsh786818m0gi4v2b9h92lkcpzxk-cairo-1.18.4-dev/include/cairo -I/nix/store/vzmdbdwiwgkd7fqzb2l2d06vyiyapmaf-freetype-2.13.3-dev/include/freetype2 -I/nix/store/vzmdbdwiwgkd7fqzb2l2d06vyiyapmaf-freetype-2.13.3-dev/include -I/nix/store/bzs48rsw4vzjvncn583flbxp8jcqfsf8-glib-2.84.4-dev/include -I/nix/store/bzs48rsw4vzjvncn583flbxp8jcqfsf8-glib-2.84.4-dev/include/glib-2.0 -I/nix/store/4gsyd6rkr7cdzbmf4cs0y47762vmbl5f-glib-2.84.4/lib/glib-2.0/include -I/nix/store/000a40dkgnybd7v1h4apn0kdwyad8qr7-librsvg-2.61.1-dev/include/librsvg-2.0 -I/nix/store/07lcl9dbssik0x6ka1if1axsm01zdq8b-gdk-pixbuf-2.42.12-dev/include/gdk-pixbuf-2.0 -I/nix/store/21fv0xlqkr83s2myp9rzyvdhb9czb6ga-libjpeg-turbo-3.1.2-dev/include -I/nix/store/bzs48rsw4vzjvncn583flbxp8jcqfsf8-glib-2.84.4-dev/include/glib-2.0 -I/nix/store/4gsyd6rkr7cdzbmf4cs0y47762vmbl5f-glib-2.84.4/lib/glib-2.0/include -g -O2 -Wall -Wextra -D_THREAD_SAFE -Wl,-export_dynamic -o .libs/smrender smath.o smfunc.o smloadosm.o smrparse.o libhpxml.o smcoast.o smgrid.o smrender.o smkap.o smqr.o smthread.o smtile.o smrules_cairo.o rdata.o median_cut.o smexec.o smcore.o smosmout.o bspline_ctrl.o cairo_jpg.o adams.o smjson.o smem.o usage.o smindex.o  -L/nix/store/il06g45n7vjjaz2kbcls70vzg25cnkrh-cairo-1.18.4/lib -L/nix/store/7xmlb4k4382i88a9lffq15llh4bj3w5d-fontconfig-2.17.1-lib/lib -L/nix/store/xms2lc3acsi2dsk8s6l883kki5a1i2d3-freetype-2.13.3/lib /nix/store/7xmlb4k4382i88a9lffq15llh4bj3w5d-fontconfig-2.17.1-lib/lib/libfontconfig.dylib /nix/store/xms2lc3acsi2dsk8s6l883kki5a1i2d3-freetype-2.13.3/lib/libfreetype.dylib -L/nix/store/yy41r1jfz748y6xq4dc54qm4xlravz95-zlib-1.3.1/lib -L/nix/store/wrzvg2lf3v7z9lgcw6yz46kxf6n3mrnh-bzip2-1.0.8/lib -L/nix/store/yhd19yha5xg5pw6kv1i9z92y1nmba470-libpng-apng-1.6.50/lib -L/nix/store/crkqy44j2bm3gan6qi6h3d2a9y8dhgvr-brotli-1.1.0-lib/lib -lz /nix/store/wrzvg2lf3v7z9lgcw6yz46kxf6n3mrnh-bzip2-1.0.8/lib/libbz2.dylib /nix/store/yhd19yha5xg5pw6kv1i9z92y1nmba470-libpng-apng-1.6.50/lib/libpng16.dylib -lbrotlidec -lpthread -L/nix/store/4gsyd6rkr7cdzbmf4cs0y47762vmbl5f-glib-2.84.4/lib -L/nix/store/n3gix4x4v8ssjf2f1zxf8nvypy6wi2xj-librsvg-2.61.1/lib -L/nix/store/zgd40w3axp4y5sd346x94f3g72zkr144-gdk-pixbuf-2.42.12/lib -lrsvg-2 -lgio-2.0 -lgdk_pixbuf-2.0 -lgobject-2.0 -lcairo -L/nix/store/v7n86rsyy28q3irpd0agdn6mvqn3pipd-libjpeg-turbo-3.1.2/lib -ljpeg -lglib-2.0 ../libsmrender/smrender/.libs/libsmrender.dylib -pthread

sikmir avatar Oct 11 '25 08:10 sikmir

I will try to compile it with clang on Linux and FreeBSD to rule out that it's a compiler issue.

rahra avatar Oct 11 '25 09:10 rahra

I now tested it on Linux and on FreeBSD with clang on both systems and it works as expected. So there is something special about your system or your version of MacOS. I know that it works (worked?) on MacOS in the past. Smrender is pretty POSIX conform and doesn't do anything special. Do you probably have another Mac somewhere to test it?

rahra avatar Oct 14 '25 13:10 rahra

Just in case:

$ /usr/bin/clang -v
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

sikmir avatar Oct 14 '25 14:10 sikmir