[LLVMdev] What different?

Chris Lattner sabre at nondot.org
Fri Dec 19 03:35:01 PST 2003


On Fri, 19 Dec 2003, yue wrote:

> hi,
> when build test echo.cpp using "llvmg++ echo.cpp -o echo"
> it create an echo file, contain:
> -------------------------------------
> [yue at RH9 Shootout-C++]$ cat echo
> #!/bin/sh
> lli \
>      -load=/usr/lib/libm.so \
>      $0.bc $*
> ---------------------------------------

This creates the 'echo.bc' file, linking in libstdc++ (the C++ runtime
library), which requires libm.

> and using "llvmgcc echo.cpp -o echo-c",
> it creates an echo-c file, contain:
> ---------------------------------------
> [yue at RH9 Shootout-C++]$ cat echo-c
> #!/bin/sh
> lli \
>      $0.bc $*
> ----------------------------------------
> why the first needs to load "libm.so" and the later does not?

In this case, it compiles the file, but doesn't link in the C++ runtime
library, because it thinks that it is a C program.  Note that you should
always use llvmg++ to link C++ programs, not llvmgcc.  This is not
specific to LLVM, native GCC has the same issue.

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/




More information about the llvm-dev mailing list