﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	difficulty
150	csc -Ob (-O5) bug (unsafe)	ddp	felix winkelmann	"[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!"	defect	closed	major		compiler	4.3.0	fixed			
