tags:

views:

91

answers:

2

I've found that if you specify a path to Alchemy's 'ar' tool, it won't create the 'l.bc' file necessary to link the library.

For example, here is the case when I don't specify a path (it works):

asimmons-mac:test asimmons$ echo 'int main() { return 42; }' > testmain.cpp
asimmons-mac:test asimmons$ echo 'int test1() { return -1; }' > test1.cpp
asimmons-mac:test asimmons$ echo 'int test2() { return 1; }' > test2.cpp
asimmons-mac:test asimmons$ g++ -c testmain.cpp
asimmons-mac:test asimmons$ g++ -c test1.cpp
asimmons-mac:test asimmons$ g++ -c test2.cpp
asimmons-mac:test asimmons$ ar cr libtest.a test1.o test2.o
asimmons-mac:test asimmons$ g++ testmain.cpp libtest.a
llvm-ld, "-o=".(98237.achacks.o = "98237.achacks.exe"), -disable-opt -internalize-public-api-list=_start,malloc,free,__adddi3,__anddi3,__ashldi3,__ashrdi3,__cmpdi2,__divdi3,__fixdfdi,__fixsfdi,__fixunsdfdi,__fixunssfdi,__floatdidf,__floatdisf,__floatunsdidf,__iordi3,__lshldi3,__lshrdi3,__moddi3,__muldi3,__negdi2,__one_cmpldi2,__qdivrem,__adddi3,__anddi3,__ashldi3,__ashrdi3,__cmpdi2,__divdi3,__qdivrem,__fixdfdi,__fixsfdi,__fixunsdfdi,__fixunssfdi,__floatdidf,__floatdisf,__floatunsdidf,__iordi3,__lshldi3,__lshrdi3,__moddi3,__muldi3,__negdi2,__one_cmpldi2,__subdi3,__ucmpdi2,__udivdi3,__umoddi3,__xordi3,__subdi3,__ucmpdi2,__udivdi3,__umoddi3,__xordi3,__error /Users/asimmons/Development/alchemy-darwin-v0.5a/avm2-libc/lib/avm2-libc.l.bc /Users/asimmons/Development/alchemy-darwin-v0.5a/avm2-libc/lib/avm2-libstdc++.l.bc, test.l.bc 98237.achacks.o

98237.achacks.swf, 5593510 bytes written
asimmons-mac:test asimmons$ ls -l
total 10992
-rwxr-xr-x  1 asimmons  staff  5593575 Apr  9 17:44 a.exe
-rw-------  1 asimmons  staff     1284 Apr  9 17:43 libtest.a
-rw-r--r--  1 asimmons  staff      672 Apr  9 17:43 test.l.bc
-rw-r--r--  1 asimmons  staff       27 Apr  9 17:43 test1.cpp
-rwxr-xr-x  1 asimmons  staff      536 Apr  9 17:43 test1.o
-rw-r--r--  1 asimmons  staff       26 Apr  9 17:43 test2.cpp
-rwxr-xr-x  1 asimmons  staff      536 Apr  9 17:43 test2.o
-rw-r--r--  1 asimmons  staff       26 Apr  9 17:43 testmain.cpp
-rwxr-xr-x  1 asimmons  staff      552 Apr  9 17:43 testmain.o
asimmons-mac:test asimmons$ 

And here is an example where I do specify a path (it doesn't work). I try to tell 'ar' to put the library under 'lib' and then link to lib/libtest.a:

asimmons-mac:test asimmons$ mkdir lib
asimmons-mac:test asimmons$ echo 'int main() { return 42; }' > testmain.cpp
asimmons-mac:test asimmons$ echo 'int test1() { return -1; }' > test1.cpp
asimmons-mac:test asimmons$ echo 'int test2() { return 1; }' > test2.cpp
asimmons-mac:test asimmons$ g++ -c testmain.cpp
asimmons-mac:test asimmons$ g++ -c test1.cpp
asimmons-mac:test asimmons$ g++ -c test2.cpp
asimmons-mac:test asimmons$ ar cr lib/libtest.a test1.o test2.o
asimmons-mac:test asimmons$ g++ testmain.cpp lib/libtest.a
llvm-ld, "-o=".(98638.achacks.o = "98638.achacks.exe"), -disable-opt -internalize-public-api-list=_start,malloc,free,__adddi3,__anddi3,__ashldi3,__ashrdi3,__cmpdi2,__divdi3,__fixdfdi,__fixsfdi,__fixunsdfdi,__fixunssfdi,__floatdidf,__floatdisf,__floatunsdidf,__iordi3,__lshldi3,__lshrdi3,__moddi3,__muldi3,__negdi2,__one_cmpldi2,__qdivrem,__adddi3,__anddi3,__ashldi3,__ashrdi3,__cmpdi2,__divdi3,__qdivrem,__fixdfdi,__fixsfdi,__fixunsdfdi,__fixunssfdi,__floatdidf,__floatdisf,__floatunsdidf,__iordi3,__lshldi3,__lshrdi3,__moddi3,__muldi3,__negdi2,__one_cmpldi2,__subdi3,__ucmpdi2,__udivdi3,__umoddi3,__xordi3,__subdi3,__ucmpdi2,__udivdi3,__umoddi3,__xordi3,__error /Users/asimmons/Development/alchemy-darwin-v0.5a/avm2-libc/lib/avm2-libc.l.bc /Users/asimmons/Development/alchemy-darwin-v0.5a/avm2-libc/lib/avm2-libstdc++.l.bc, lib/test.l.bc 98638.achacks.o
llvm-ld: error: Cannot find linker input 'lib/test.l.bc'
asimmons-mac:test asimmons$ ls -l
total 56
-rw-r--r--  1 asimmons  staff  552 Apr  9 17:46 98638.achacks.o
drwxr-xr-x  3 asimmons  staff  102 Apr  9 17:46 lib
-rw-r--r--  1 asimmons  staff   27 Apr  9 17:45 test1.cpp
-rwxr-xr-x  1 asimmons  staff  536 Apr  9 17:46 test1.o
-rw-r--r--  1 asimmons  staff   26 Apr  9 17:45 test2.cpp
-rwxr-xr-x  1 asimmons  staff  536 Apr  9 17:46 test2.o
-rw-r--r--  1 asimmons  staff   26 Apr  9 17:45 testmain.cpp
-rwxr-xr-x  1 asimmons  staff  552 Apr  9 17:45 testmain.o
asimmons-mac:test asimmons$ ls -l lib/
total 8
-rw-------  1 asimmons  staff  1284 Apr  9 17:46 libtest.a
asimmons-mac:test asimmons$

but the linker errors out because it can't find lib/test.l.bc. Notice how in the first example, 'test.l.bc' was generated alongside libtest.a. But in the second example test.l.bc was not generated. Where did it go?

This is a contrived example, but in the project I'm trying to build with alchemy the make scripts generate libraries in full paths and then refer to them that way. It seems that alchemy's 'ar' tool is broken if you try to generate a library anywhere other than '.'.

Has anyone else seen this? Is there a workaround?

fyi, I've also posted this question on the Alchemy formus.

A: 

Yes I have found this to happen to me too. My solution was to just create the libraries in the current directory and just mv it to the appropriate directory after it was created. As for the reason why, I do not know.

jonathanasdf
I guess this is the only workaround for now. I was able to hack around the problem in my project's CMake scripts and make it create the libs in the binary output dir and not some subdir of it.
paleozogt
A: 

There seems to be a bug in the 'ar' tool, but here's the workaround.

paleozogt