bluespec.com Forum Index bluespec.com
Bluespec Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Bluesim linkage failure

 
Post new topic   Reply to topic    bluespec.com Forum Index -> Tools: Bluesim
View previous topic :: View next topic  
Author Message
kfleming



Joined: 20 Feb 2010
Posts: 5

PostPosted: Sat Feb 20, 2010 8:30 pm    Post subject: Bluesim linkage failure Reply with quote

I get the following error in running a bluesim executable. addNoise is an imported bdpi function, and bsc runs without error.

Error: dlopen: .bsc/bcjr_test_hw.exe.so: undefined symbol: addNoise
invoked from within
"sim load $model_name"
invoked from within
"if {$wait} {
sim load $model_name wait
} else {
sim load $model_name
}"
(file "/usr/local/lib/Bluespec-2009.11.beta1//lib//tcllib/bluespec/bluesim.tcl" line 171)

When I dump the library symbols, I don't see the referenced symbol. However, if I build an old version of the code, I see that the library doesn't have the symbol either, but the bluesim works.


I have changed the build process: the bdpi bas do not all reside in the same directory, and this may be a problem. I suspect that some file is not being linked in to the library, but I do not know if this is the responsibility of bluesim or if I have to do something. I do notice that (no surprise here) the generated .o files have the symbols I am looking for. How do I fix this?

-E
Back to top
View user's profile Send private message
jnewbern



Joined: 18 Jul 2007
Posts: 71

PostPosted: Mon Feb 22, 2010 10:41 am    Post subject: Reply with quote

Elliott,

Can you supply the command lines that are used to build your bluesim executable? One thing that will cause this error is if the .o file (or .c file) is not included on the command line during the the bsc link step.

If you use the -v option to bsc, it should show all of the relevant build steps, including the creation of the .so file. The first thing to do is make sure that the .o file gets included in g++ command that creates the .so file.

Jeff
Back to top
View user's profile Send private message
kfleming



Joined: 20 Feb 2010
Posts: 5

PostPosted: Tue Feb 23, 2010 1:28 am    Post subject: Command line etc. Reply with quote

I see my problem. I did for get to include a file on the command line. But I am wondering why the dlopen failed, and in any case, that error message was rather misleading. Could you fix it?
Back to top
View user's profile Send private message
jnewbern



Joined: 18 Jul 2007
Posts: 71

PostPosted: Tue Feb 23, 2010 12:55 pm    Post subject: Reply with quote

Elliott,

Because Bluesim is generating a dynamic loadable shared library, the linker does not require that all of the symbols be resolved at link time -- the symbols may be resolved when the library is actually loaded (you may be importing functions from libc, for example). This is actually a feature, not a bug.

However, when you forget to include a file then the unresolved symbols go unreported, in the expectation that they will be resolved when the library is loaded. When the dlopen happens and the symbols aren't found, that's when you get the error.

What we would like to do is have the compiler issue a warning at link time if there are unresolved symbols. This will let you know earlier and provide a more informative message. It will be a warning, though, not an error because some people do use the feature of resolving symbols at library load time.

Jeff
Back to top
View user's profile Send private message
kfleming



Joined: 20 Feb 2010
Posts: 5

PostPosted: Tue Feb 23, 2010 12:59 pm    Post subject: Reply with quote

That is also a good idea, but I also think that a suggestion that you might be missing source or object files would still be useful, even at runtime, in case you missed the warning. It certainly would have saved this conversation. Could there be a flag that would make the warning an error, like -Werror or something of that kind?
Back to top
View user's profile Send private message
jnewbern



Joined: 18 Jul 2007
Posts: 71

PostPosted: Tue Feb 23, 2010 1:01 pm    Post subject: Reply with quote

Yes, that would be part of the link-time warning message.
Back to top
View user's profile Send private message
kfleming



Joined: 20 Feb 2010
Posts: 5

PostPosted: Tue Feb 23, 2010 1:02 pm    Post subject: Reply with quote

I edited my previous, highly unclear post. Sorry about that.
Back to top
View user's profile Send private message
vmurali



Joined: 30 Jul 2008
Posts: 11

PostPosted: Thu Aug 16, 2012 1:07 pm    Post subject: Bluesim link problem (dlopen error) unresolved Reply with quote

I run into the same issue. I have double checked if I have included the .cpp file while calling bsc for linking. I also made sure that the c++ command includes the .o file for creating the a.out.so. Here are my commands (and relevant outputs):

Code:

$ bsc -aggressive-conditions -u -sim -p +:/home/vmurali/SMIPS/simulator/lib -bdir bdir -simdir bdir -info-dir bdir -vdir bdir +RTS -K1G -RTS  /home/vmurali/SMIPS/simulator/lib/TestBench.bsv

$ bsc -u -sim -verbose -e mkTestBench bdir/*.ba bdir/*.cpp
exec: c++ -O3 -g -Wall -Wno-unused -D_FILE_OFFSET_BITS=64 -fpermissive -fPIC -c -o bdir/system.o bdir/system.cpp
User object created: bdir/system.o
exec: c++ -O3 -g -Wall -Wno-unused -D_FILE_OFFSET_BITS=64 -shared -fPIC -Wl,-Bsymbolic -Wl,--version-script="/afs/csail/group/csg/tools/tools_lx86/bluespec/current/lib/Bluesim/bs_linux_export_map.txt" -o a.out.so mkTestBench.o mkProc.o bdir/system.o mkCop.o mkDMemory.o mkIMemory.o mkRFile.o module_alu.o module_aluBr.o module_brAddrCalc.o module_decode.o module_exec.o model_mkTestBench.o /afs/csail/group/csg/tools/tools_lx86/bluespec/current/lib/Bluesim/g++4_64/libbskernel.a /afs/csail/group/csg/tools/tools_lx86/bluespec/current/lib/Bluesim/g++4_64/libbsprim.a -lm
exec: strip -x a.out.so
Simulation shared library created: a.out.so
Simulation executable created: a.out


$ bsc -v
Bluespec Compiler, version 2012.05.beta1 (build 28702, 2012-05-14)



Is there some default directory which is searched during the dynamic loading phase? I tried placing the .o file in a number of places, but to no avail.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    bluespec.com Forum Index -> Tools: Bluesim All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
bluespec.com topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP