LLVM-2.5 WinXP/Cygwin can't find puts() for the hello.c in GettingStarted document

I am using LLVM 2.5 release, together with llvm-gcc4.2-2.5.
For the hello.c demo testing found close to the end of the GettingStarted document:

#include <stdio.h>

int main() {
  printf("hello world\n");
  return 0;

Following the instructions:
obtaining the bc file: /llvm-gcc -O3 -emit-llvm hello.c -c -o hello.bc/
running through lli: * */lli hello.bc/

I got this error msg: /*ERROR: Program used external function 'puts' which could not be resolved! Abort*/

I think this might have to do with my LD_LIBRARY_PATH settings, thus explicitly checked that it includes a path to libc,
echo $LD_LIBRARY_PATH: *//lib:/usr/lib:/opt/llvm-2.5/lib:.:/home/czhao/suif/suif_1.3.0/i686-cygwin-cygwin/solib//*

How could I fix this WinXP/Cygwin only thing?

I tried the same steps on a Debian4-i386 machine, everything works fine.

Thank you very much



The bc code of the hello.c file:
llvm-dis < hello.bc:

; ModuleID = '<stdin>'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
target triple = "i386-mingw32"
@.str = internal constant [13 x i8] c"Hello, world\00" ; <[13 x i8]*> [#uses=1]

define i32 @main() nounwind {
    %0 = tail call i32 @puts(i8* getelementptr ([13 x i8]* @.str, i32 0, i32 0)) nounwind ; <i32> [#uses=0]
    ret i32 0

declare i32 @puts(i8*)

Hi, Chuck

How could I fix this WinXP/Cygwin only thing?

windows does not support dynamic linking, so there are 2 ways of
providing external addresses of symbols:
1. register them explicitly
2. They should be available from some .DLL already preloaded into the binary.

However, I'm not sure for 2. since cygwin uses unix-style of external
symbols resolution.

Thanks, Anton,

I find it hard to believe, as LLVM’s CYGWIN path has been there for a long time.
This can’t be a new problem.
Somebody must have incurred and solved it before.
Otherwise, a significant portion or LLVM tests or test-suites will fail. How could the sanity test go through?

For people who use CYGWIN/LLVM as your default platform, how do you solve this problem?
Or, if there isn’t such a problem, my Cygwin env is strange.

Thank you very much


Anton Korobeynikov wrote: