Compiling SAFECode poolalloc in cygwin create different libraries compared to linux.

Hi,

On Linux I observed

[root@localhost poolalloc]# find . -name *.a
./Release+Asserts/lib/LLVMDataStructure.a
./Release+Asserts/lib/poolalloc.a
./Release+Asserts/lib/AssistDS.a
./Release+Asserts/lib/libpoolalloc_fl_rt.a
./Release+Asserts/lib/libpoolalloc_rt.a
./Release+Asserts/lib/libpa_pre_rt.a
./Release+Asserts/lib/libcount.a

On cygwin I observed

kpawar@KPAWAR-LT ~/SAFECode/LLVM_SRC/llvm/projects/poolalloc
$ find . -name *.a
./Release+Asserts/lib/libAssistDS.a
./Release+Asserts/lib/libcount.a
./Release+Asserts/lib/libLLVMDataStructure.a
./Release+Asserts/lib/libpa_pre_rt.a
./Release+Asserts/lib/libpoolalloc.a
./Release+Asserts/lib/libpoolalloc_fl_rt.a
./Release+Asserts/lib/libpoolalloc_rt.a
./Release+Asserts/lib/libtypechecks_rt.a

This creates issue to llvm/safecode since it tries to search libraries named as poolalloc.a, AssistDS.a etc. Any solution for this ?

~ Kiran

Dear Kiran,

Which version of LLVM/SAFECode are you using? Is it LLVM 3.2?

I'm guessing that you're using LLVM 3.2 and trying to compile safecode/tools/LTO (that's the only component that links in AssistDS.a). You could try changing the following line:

$(PROJ_OBJ_ROOT)/$(BuildMode)/lib/libAssistDS.a: $(POOLALLOC_OBJDIR)/$(BuildMode)/lib/AssistDS.a

... to:

$(PROJ_OBJ_ROOT)/$(BuildMode)/lib/libAssistDS.a: $(POOLALLOC_OBJDIR)/$(BuildMode)/lib/libAssistDS.a

You'll need to fix the problem for other libraries for which SAFECode creates links in its own object tree (such as libpoolalloc.a).

That might fix the problem on Cygwin.

Regards,

John Criswell

Hi John,

That worked for me. I am using llvm 3.2 only and following http://safecode.cs.illinois.edu/docs/Install.html

So for I am able to make inside llvm/projects/poolalloc by doing such cosmetic changes.

Now, when I tried to make inside llvm/projects/safecode, I see another error.

kpawar@KPAWAR-LT ~/SAFECode/LLVM_SRC/llvm/projects/safecode
$ /usr/bin/clang -cc1 -triple i386-pc-windows-cygnus -emit-obj -disable-free -disable-llvm-verifier -main-file-name Parser.cpp -mrelocation-model static -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -target-linker-version 2.25 -dwarf-column-info -coverage-file /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/Release+Asserts/Parser.o -resource-dir /usr/bin/…/lib/clang/i686-pc-cygwin/3.5.2 -dependency-file /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/Release+Asserts/Parser.d.tmp -MP -MT /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/Release+Asserts/Parser.o -MT /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/Release+Asserts/Parser.d -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D SAFECODE -D SAFECODE -I /home/kpawar/SAFECode/LLVM_SRC/llvm/include -I /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/include -I /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse -I /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/…/…/include -I /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/…/…/include -I /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/poolalloc/include -I /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/poolalloc/include -I /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/poolalloc/include -I /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/poolalloc/include -O3 -Woverloaded-virtual -Wcast-qual -Wall -Wno-deprecated -Wall -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcovered-switch-default -pedantic -fdebug-compilation-dir /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse -ferror-limit 19 -fmessage-length 271 -fvisibility-inlines-hidden -mstackrealign -fno-rtti -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/Release+Asserts/Parser.o -x c++ tools/clang/lib/Parse/Parser.cpp
Stack dump:
0. Program arguments: /usr/bin/clang -cc1 -triple i386-pc-windows-cygnus -emit-obj -disable-free -disable-llvm-verifier -main-file-name Parser.cpp -mrelocation-model static -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -target-linker-version 2.25 -dwarf-column-info -coverage-file /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/Release+Asserts/Parser.o -resource-dir /usr/bin/…/lib/clang/i686-pc-cygwin/3.5.2 -dependency-file /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/Release+Asserts/Parser.d.tmp -MP -MT /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/Release+Asserts/Parser.o -MT /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/Release+Asserts/Parser.d -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D SAFECODE -D SAFECODE -I /home/kpawar/SAFECode/LLVM_SRC/llvm/include -I /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/include -I /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse -I /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/…/…/include -I /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/…/…/include -I /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/poolalloc/include -I /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/poolalloc/include -I /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/poolalloc/include -I /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/poolalloc/include -O3 -Woverloaded-virtual -Wcast-qual -Wall -Wno-deprecated -Wall -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcovered-switch-default -pedantic -fdebug-compilation-dir /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse -ferror-limit 19 -fmessage-length 271 -fvisibility-inlines-hidden -mstackrealign -fno-rtti -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/Release+Asserts/Parser.o -x c++ tools/clang/lib/Parse/Parser.cpp

  1. /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/…/…/include/clang/Sema/DeclSpec.h:855:3: current parser token ‘SourceLocation’
  2. /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/…/…/include/clang/Sema/DeclSpec.h:38:1: parsing namespace ‘clang’
  3. /home/kpawar/SAFECode/LLVM_SRC/llvm/projects/safecode/tools/clang/lib/Parse/…/…/include/clang/Sema/DeclSpec.h:783:1: parsing struct/union/class body ‘UnqualifiedId’

~ Kiran

Dear Kiran,

Egads! It looks like /usr/bin/clang is crashing. This isn't a bug in SAFECode; it's a bug in Clang.

What version of Clang are you using in Cygwin to compile SAFECode?

One thing you should try is compiling Clang 3.2 in Cygwin (either using gcc or clang). SAFECode Clang is standard Clang modified with a few new command-line options to run the SAFECode transformation passes. If unmodified Clang 3.2 won't compile on Cygwin, then SAFECode Clang for LLVM 3.2 won't compile either.

BTW, are you working with Nikhil?

Regards,

John Criswell

Hi John,
Yes I am working with Nikhil.
I compiled Clang 3.2 in Cygwin using gcc ( note- with clang there were lot of errors during compilation). Going ahead, Installation is successful for me.

However there new issue with SAFECode clang installed in cygwin.

If you check below snippet it looks like clang invoke gcc which in-turn fails to recognize ‘-fmemsafety’ and so sample.exe is not created.

Any clue why clang fallback to gcc ? On my linux machine I do not see gcc invocation.

Excellent. My best guess is that the Clang compiler driver is written to use gcc to link object files together (as opposed to calling ld directly). Note that Clang runs clang to create /tmp/sample-T1WCmN.s (which I assume is the assembly code created by Clang). When I modified Clang to pass the “-fmemsafety” option from the Clang compiler driver to the Clang compiler (yes, Clang runs itself to compile code), I must have done it in a way that also causes Clang to pass “-fmemsafety” to the linker command line also (which works if Clang is performing the link but not if GCC is). Take a look at safecode/tools/clang/lib/Driver/Tools.cpp. The method Clang::ConstructJob() adds the “-fmemsafety” option to the command line. You may need to modify Tools.cpp so that the code that constructs the link command line remove this option (and other SAFECode options). That’s my best guess at the moment. Regards, John Criswell