lcn2 / calc

C-style arbitrary precision calculator
http://www.isthe.com/chongo/tech/comp/calc/index.html
Other
346 stars 52 forks source link

Bug: Messy Installation with BLD_TYPE=calc-static-only #89

Closed TurtleWilly closed 1 year ago

TurtleWilly commented 1 year ago

Calc bug report template version: 1.3 2022-11-27

Describe the bug If we build calc with the BLD_TYPE=calc-static-only option as described in the HOWTO.INSTALL file the installation gets slightly messy.

(1) It installs the calc binary twice, once as calc and once as calc-static. The second one seems to be a bit superfluous and a waste of disk space, IMHO.

$ ls -l /usr/local/mystuff/calc/2.14.3.0/bin 
total 3168
-rwxr-xr-x  1 root  wheel  807736 Aug  9 14:22 calc
-rwxr-xr-x  1 root  wheel  807736 Aug  9 14:22 calc-static

$ md5sum /usr/local/mystuff/calc/2.14.3.0/bin/*
00818048f4bc32d0c461413ca9f157de  /usr/local/mystuff/calc/2.14.3.0/bin/calc
00818048f4bc32d0c461413ca9f157de  /usr/local/mystuff/calc/2.14.3.0/bin/calc-static

(2) it fails to handle now missing .dylibs during the make install and creates some dead-end soft links:

…
installed /usr/local/mystuff/calc/2.14.3.0/share/calc/cscript/simple
installed /usr/local/mystuff/calc/2.14.3.0/share/calc/cscript/square
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /usr/local/mystuff/calc/2.14.3.0/lib/libcalc.a(strl.o) has no symbols
installed /usr/local/mystuff/calc/2.14.3.0/lib/libcalc.a
cp: libcalc.2.14.3.0.dylib: No such file or directory
chmod: /usr/local/mystuff/calc/2.14.3.0/lib/libcalc.2.14.3.0.dylib.new: No such file or directory
mv: rename /usr/local/mystuff/calc/2.14.3.0/lib/libcalc.2.14.3.0.dylib.new to /usr/local/mystuff/calc/2.14.3.0/lib/libcalc.2.14.3.0.dylib: No such file or directory
installed /usr/local/mystuff/calc/2.14.3.0/lib/libcalc.2.14.3.0.dylib
installed /usr/local/mystuff/calc/2.14.3.0/lib/libcalc.dylib
cp: custom/libcustcalc.2.14.3.0.dylib: No such file or directory
chmod: /usr/local/mystuff/calc/2.14.3.0/lib/libcustcalc.2.14.3.0.dylib.new: No such file or directory
mv: rename /usr/local/mystuff/calc/2.14.3.0/lib/libcustcalc.2.14.3.0.dylib.new to /usr/local/mystuff/calc/2.14.3.0/lib/libcustcalc.2.14.3.0.dylib: No such file or directory
installed /usr/local/mystuff/calc/2.14.3.0/lib/libcustcalc.2.14.3.0.dylib
installed /usr/local/mystuff/calc/2.14.3.0/lib/libcalc.dylib
installed /usr/local/mystuff/calc/2.14.3.0/include/calc/alloc.h
installed /usr/local/mystuff/calc/2.14.3.0/include/calc/banned.h
…
$ ls -l /usr/local/mystuff/calc/2.14.3.0/lib/
total 4600
-rw-r--r--  1 root  wheel  2247696 Aug  9 14:22 libcalc.a
lrwxr-xr-x  1 root  wheel       22 Aug  9 14:22 libcalc.dylib -> libcalc.2.14.3.0.dylib
-rw-r--r--  1 root  wheel    96648 Aug  9 14:22 libcustcalc.a
lrwxr-xr-x  1 root  wheel       26 Aug  9 14:22 libcustcalc.dylib -> libcustcalc.2.14.3.0.dylib

$ stat -L  /usr/local/mystuff/calc/2.14.3.0/lib/libcalc.dylib 
stat: /usr/local/mystuff/calc/2.14.3.0/lib/libcalc.dylib: stat: No such file or directory

$ stat -L  /usr/local/mystuff/calc/2.14.3.0/lib/libcustcalc.dylib 
stat: /usr/local/mystuff/calc/2.14.3.0/lib/libcustcalc.dylib: stat: No such file or directory

To Reproduce

Build calc with the BLD_TYPE=calc-static-only argument, e.g.:

MACOSX_DEPLOYMENT_TARGET=10.10 sudo make \
    PREFIX=/usr/local/mystuff/calc/2.14.3.0 \
    LDFLAGS='-Wl,-headerpad_max_install_names -Wl,-dead_strip' \
    USE_READLINE='-DUSE_READLINE' \
    READLINE_LIB='-L/usr/local/mystuff/readline/latest/lib -lreadline' \
    READLINE_EXTRAS='-lhistory -lncurses' \
    CALC_INCDIR='/usr/local/mystuff/calc/2.14.3.0/include/calc' \
    CALC_SHAREDIR='/usr/local/mystuff/calc/2.14.3.0/share/calc' \
    MANDIR='/usr/local/mystuff/calc/2.14.3.0/share/man' \
    SCRIPTDIR='/usr/local/mystuff/calc/2.14.3.0/share/calc/cscript' \
    BLD_TYPE=calc-static-only \
    install

Expected behavior

(1) Only install a single calc binary.

(2) Don't create dead-end symlinks, don't error during make install.

Attach debug.out IMPORTANT: Please run make debug and then attach the debug.out file. n/a

Screen shots If applicable, attach screen shots to help explain your problem. n/a

Execution environment (please complete the following information):

Calc mods If you have modified the calc source for some reason, please description what you modified. Please consider attaching a patch (diff -u) between an official calc release and the source you are using.

n/a

Patch If you have a recommended code patch to address the problem, please attach your file

n/a

Additional context Add any other context about the problem here.

n/a

lcn2 commented 1 year ago

Hello @TurtleWilly,

We believe we have fixed these problems in our local development tree. We will be testing the fix a bit more before pushing the code to the top of the master branch.

lcn2 commented 1 year ago

With commit 3bfcaae76782ccf448be80843a24ffd89373cd13 this issue has been resolved, @TurtleWilly .

In particular:

Improved .gitignore to ignore .static, calc-static,
sample_many-static and sample_rand-static.

Improved error messages when trying to compile with
with one calc type (when BLD_TYPE=calc-dynamic-only or
BLD_TYPE=calc-static-only) and install with the other.

When installing with BLD_TYPE=calc-static-only, the
installed calc and calc-static are links to each other.
Thanks to GitHub user @TurtleWilly for this suggestion.

The dynamic shared libraries are not installed if they are not
built.  So when installing with BLD_TYPE=calc-static-only, the
install rule will not attempt to install dynamic shared libraries.
Thanks to GitHub user @TurtleWilly for bringing to our attention,
problems related to building a statically linked calc under macOS.

These changes were also tested under RHEL9 Linux.

It is currently at the top of the master branch. After addressing issue #88 , we plan to release a new version of calc.

Thank you for bringing this problem to our attempting. We will now close this issue as completed.

TurtleWilly commented 1 year ago

I tested 3bfcaae here on my system and it seems to work well. The both calc binaries are now hardlinks to each other (same inode), and no more broken dylib links or related errors during make install. 👍