Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#150 closed defect (fixed)

csc -Ob (-O5) bug (unsafe)

Reported by: ddp Owned by: felix winkelmann
Priority: major Milestone:
Component: compiler Version: 4.3.0
Keywords: Cc:
Estimated difficulty:

Description

[Mac OS X, 10.6.2 (Snow Leopard), Chicken 4.3.0]

There's a bug with the unsafe processing in csc. When it's compiling unsafe, it doesn't reflect this out to the 'install_name_tool' invocation, resulting in no fixup in the resulting image. So if libuchicken.dylib doesn't happen to be in the standard library search path, it blows up at runtime:

fluffy656% csc -verbose hello.scm
/usr/local/chicken/bin/chicken hello.scm -output-file hello.c -verbose
Loading compiler extensions...
debugging info: calltrace
loading identifier database /usr/local/chicken/lib/chicken/4/modules.db ...
compiling `hello.scm' ...
pass: source
pass: canonicalized
pass: initial node tree
pass: cps
pass: analysis
pass: optimized-iteration
pass: analysis
pass: optimized-iteration
pass: analysis
pass: optimized-iteration
pass: analysis
pass: optimized
pass: final-analysis
pass: closure-converted
generating `hello.c' ...
compilation finished.
gcc hello.c -o hello.o -c -no-cpp-precomp -fno-strict-aliasing -fno-common -DHAVE_CHICKEN_CONFIG_H
-m64 -DC_ENABLE_PTABLES -Os -fomit-frame-pointer -I/usr/local/chicken/include
rm hello.c
gcc hello.o -o hello -m64 -L/usr/local/chicken/lib -lchicken -lm
install_name_tool -change libchicken.dylib /usr/local/chicken/lib/libchicken.dylib hello
rm hello.o
fluffy657% otool -L hello
hello:

/usr/local/chicken/lib/libchicken.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.0)

fluffy658% ./hello
Hello, World!

fluffy659% csc -O5 -verbose hello.scm
/usr/local/chicken/bin/chicken hello.scm -output-file hello.c -unsafe-libraries -optimize-level
5 -verbose
Loading compiler extensions...
debugging info: none
loading identifier database /usr/local/chicken/lib/chicken/4/modules.db ...
compiling `hello.scm' ...
pass: source
pass: canonicalized
pass: initial node tree
pass: analysis
pass: lambda lifted
pass: cps
pass: analysis
pass: optimized-iteration
pass: analysis
pass: optimized-iteration
pass: analysis
pass: optimized-iteration
pass: analysis
pass: optimized
pass: final-analysis
pass: closure-converted
generating `hello.c' ...
compilation finished.
gcc hello.c -o hello.o -c -no-cpp-precomp -fno-strict-aliasing -fno-common -DHAVE_CHICKEN_CONFIG_H
-m64 -DC_ENABLE_PTABLES -Os -fomit-frame-pointer -O3 -fomit-frame-pointer -I/usr/local/chicken/include
rm hello.c
gcc hello.o -o hello -m64 -L/usr/local/chicken/lib -luchicken -lm
install_name_tool -change libchicken.dylib /usr/local/chicken/lib/libchicken.dylib hello
rm hello.o
fluffy660% otool -L hello
hello:

libuchicken.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.0)

fluffy661% ./hello
dyld: Library not loaded: libuchicken.dylib

Referenced from: /Users/ddp/src/scm/./hello
Reason: image not found

Trace/BPT trap
fluffy662% install_name_tool -change libuchicken.dylib
/usr/local/chicken/lib/libuchicken.dylib hello
fluffy663% ./hello
Hello, World!

Attachments (2)

csc.scm.patch (1.8 KB) - added by ddp 13 years ago.
patch
csc.scm.2.patch (2.5 KB) - added by ddp 13 years ago.
a better patch

Download all attachments as: .zip

Change History (6)

Changed 13 years ago by ddp

Attachment: csc.scm.patch added

patch

Changed 13 years ago by ddp

Attachment: csc.scm.2.patch added

a better patch

comment:1 Changed 13 years ago by ddp

Milestone: 4.3.04.4.0

comment:2 Changed 13 years ago by felix winkelmann

Owner: set to felix winkelmann
Status: newaccepted

comment:3 Changed 13 years ago by felix winkelmann

Resolution: fixed
Status: acceptedclosed

Patch applied in commit 076d3c14ef009d430fc8cb3458c3a1ecd478c113 (master). Thanks a lot.

comment:4 Changed 13 years ago by (none)

Milestone 4.4.0 deleted

Note: See TracTickets for help on using tickets.