Program received SIGSEGV - invalid memory reference - windows

I wrote a small linker in fortran-cpp to read a file with some numbers.
$cat mainProg.f
program fprogram
real*8 c(30)
do i=1,30
c(i) = i * 1.0
end do
print*,"Before calling cpp function"
c PASS ARRAY "C" TO CPP
call pass_to_cpp(c)
print*,"After calling cpp function"
do i=1,30
print*,' c =',c(i)
end do
print*,"I'm done here ..!!"
c stop
end
and,
$cat cprog.C
#include<iostream>
#include<cmath>
#include<fstream>
using namespace std;
extern "C" {
void pass_to_cpp_(double *c);
}
void pass_to_cpp_(double *c)
{
ifstream myfile ("example.txt");
for(int i=0; i<30; i++)
{
myfile >> c[i];
cout <<"called = " << i << "\n";
}
}
I am building this on ubuntu 16.04 to be run on a windows machine. I am usin mingw for compiling.
Here is the error on windows:
called = 0
Program received a signal SIGSEGV: Segmentation fault - invalid memory reference
Backtrace for this error:
#0 ffffffffffffff
#1 ffffffffffffff
#2 ffffffffffffff
#3 ffffffffffffff
#4 ffffffffffffff
#5 ffffffffffffff
#6 ffffffffffffff
#7 ffffffffffffff
#8 ffffffffffffff
#9 ffffffffffffff
#10 ffffffffffffff
#11 ffffffffffffff
#12 ffffffffffffff
#13 ffffffffffffff
#14 ffffffffffffff
#15 ffffffffffffff
File 'example.txt' is a simple file with 30 numbers.
Any suggestions on what is the cause of the error?
I compiled with this:
$ x86_64-w64-mingw32-gfortran -c main_read.f
$ x86_64-w64-mingw32-g++ -c cread.C
$ x86_64-w64-mingw32-gfortran -o read.exe main_read.o cread.o -lstdc++ -static
If I dont use -static, it complains 'libgfortran3.dll not found'.

Related

LLC.exe cannot produce assembly

I have a very simple C program called simple.c, and I want to use the LLVM toolchain to first produce IR Bitcode, then compile and link the bitcode myself.
This is what I currently do:
clang -O3 -emit-llvm simple.c -c -o simple.bc
llc -filetype=obj simple.bc <---- this is where it fails
simple.c
#include <stdio.h>
int main(void){
printf("Hello, World!\n");
return 0;
}
i can run the code when i compile it directly with clang, and i can run the bitcode with lli, however llc fails with this:
```C:\Users\Dvino\Desktop\hovet\hovet>llc -filetype=obj simple.bc
Stack dump:
0. Program arguments: llc -filetype=obj simple.bc
1. Running pass 'Function Pass Manager' on module 'simple.bc'.
2. Running pass 'Expand Atomic instructions' on function '#main'
#0 0x0fa3aed0 (C:\Windows\SYSTEM32\ucrtbased.dll+0x8aed0)
#1 0x0fa3d9ec (C:\Windows\SYSTEM32\ucrtbased.dll+0x8d9ec)
#2 0x0fa3dfc0 (C:\Windows\SYSTEM32\ucrtbased.dll+0x8dfc0)
#3 0x02800def (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x2430def)
#4 0x029a3490 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x25d3490)
#5 0x03f8b086 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x3bbb086)
#6 0x03f8b279 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x3bbb279)
#7 0x03f8ce06 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x3bbce06)
#8 0x03f8dba8 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x3bbdba8)
#9 0x00b84936 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x7b4936)
#10 0x00b7b056 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x7ab056)
#11 0x00b7b2d6 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x7ab2d6)
#12 0x00b78215 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x7a8215)
#13 0x00b84df6 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x7b4df6)
#14 0x00b86408 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x7b6408)
#15 0x01cc60d8 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x18f60d8)
#16 0x01cc4824 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x18f4824)
#17 0x01afa507 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x172a507)
#18 0x01a11eaf (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x1641eaf)
#19 0x01a0f0f6 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x163f0f6)
#20 0x02739ff3 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x2369ff3)
#21 0x02d448e2 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x29748e2)
#22 0x02d44bf4 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x2974bf4)
#23 0x02d45d52 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x2975d52)
#24 0x02d46595 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x2976595)
#25 0x02d3ff8d (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x296ff8d)
#26 0x006781a6 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x2a81a6)
#27 0x00678ed2 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x2a8ed2)
#28 0x044cde5e (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x40fde5e)
#29 0x044cdcf7 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x40fdcf7)
#30 0x044cdb8d (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x40fdb8d)
#31 0x044cded8 (C:\Users\Dvino\Desktop\hovet\hovet\llc.exe+0x40fded8)
#32 0x750f8494 (C:\Windows\System32\KERNEL32.DLL+0x18494)
#33 0x777f41c8 (C:\Windows\SYSTEM32\ntdll.dll+0x641c8)
#34 0x777f4198 (C:\Windows\SYSTEM32\ntdll.dll+0x64198)
```

How Get llvm Library in Go?

My OS is GNU/Ubuntu 16.10- 64bit.
i also report this to GoLang.
https://github.com/golang/go/issues/19444
$ go get llvm.org/llvm/bindings/go/llvm
package llvm.org/llvm/bindings/go/llvm: unrecognized import path "llvm.org/llvm/bindings/go/llvm" (parse https://llvm.org/llvm/bindings/go/llvm?go-get=1: no go-import meta tags ())
$ go get llvm.org/llvm/bindings
package llvm.org/llvm/bindings: unrecognized import path "llvm.org/llvm/bindings" (parse https://llvm.org/llvm/bindings?go-get=1: no go-import meta tags ())
so go get say not parse https://llvm.org/llvm/bindings?go-get=1
in browser also https://llvm.org/ not open.(HTTPS)
Not Found
The requested URL / was not found on this server.
Apache/2.2.22 (Ubuntu) Server at llvm.org Port 443
but http://llvm.org is good.(HTTP)
how can get this libs for GoLang?
==================
Try github.com/go-llvm/llgo :
guest#system:~/go/src/github.com/go-llvm/llgo$ ./llgo-go.sh build
can't load package: package github.com/go-llvm/llgo: no buildable Go source files in /home/guest/go/src/github.com/go-llvm/llgo
guest#system:~/go/src/github.com/go-llvm/llgo$ ./llgo-go.sh install
can't load package: package github.com/go-llvm/llgo: no buildable Go source files in /home/guest/go/src/github.com/go-llvm/llgo
guest#system:~/go/src/github.com/go-llvm/llgo$ ./llgo-go.sh install
can't load package: package github.com/go-llvm/llgo: no buildable Go source files in /home/guest/go/src/github.com/go-llvm/llgo
guest#system:~/go/src/github.com/go-llvm/llgo$ make
./update_clang.sh
can't load package: package llvm.org/llvm/bindings/go/llvm: cannot find package "llvm.org/llvm/bindings/go/llvm" in any of:
/usr/lib/go-1.8/src/llvm.org/llvm/bindings/go/llvm (from $GOROOT)
/home/guest/go/src/llvm.org/llvm/bindings/go/llvm (from $GOPATH)
Makefile:25: recipe for target 'workdir/.update-clang-stamp' failed
make: *** [workdir/.update-clang-stamp] Error 1
guest#system:~/go/src/github.com/go-llvm/llgo$ export PATH=/path/to/gcc-inst/bin:$PATH
guest#system:~/go/src/github.com/go-llvm/llgo$ export LD_LIBRARY_PATH=/path/to/gcc-inst/lib64:$LD_LIBRARY_PATH
guest#system:~/go/src/github.com/go-llvm/llgo$ export CC=`which gcc`
guest#system:~/go/src/github.com/go-llvm/llgo$ export CXX=`which g++`
guest#system:~/go/src/github.com/go-llvm/llgo$ export LIBGO_CFLAGS=--gcc-toolchain=/path/to/gcc-inst
guest#system:~/go/src/github.com/go-llvm/llgo$ go get -d github.com/go-llvm/llgo/cmd/gllgo
package llvm.org/llvm/bindings/go/llvm: unrecognized import path "llvm.org/llvm/bindings/go/llvm" (parse https://llvm.org/llvm/bindings/go/llvm?go-get=1: no go-import meta tags ())
package golang.org/x/tools/go/exact: cannot find package "golang.org/x/tools/go/exact" in any of:
/usr/lib/go-1.8/src/golang.org/x/tools/go/exact (from $GOROOT)
/home/guest/go/src/golang.org/x/tools/go/exact (from $GOPATH)
package golang.org/x/tools/go/gccgoimporter: cannot find package "golang.org/x/tools/go/gccgoimporter" in any of:
/usr/lib/go-1.8/src/golang.org/x/tools/go/gccgoimporter (from $GOROOT)
/home/guest/go/src/golang.org/x/tools/go/gccgoimporter (from $GOPATH)
package golang.org/x/tools/go/importer: cannot find package "golang.org/x/tools/go/importer" in any of:
/usr/lib/go-1.8/src/golang.org/x/tools/go/importer (from $GOROOT)
/home/guest/go/src/golang.org/x/tools/go/importer (from $GOPATH)
guest#system:~/go/src/github.com/go-llvm/llgo$ $GOPATH/src/llvm.org/llvm/bindings/go/build.sh -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=host
bash: /home/guest/go/src/llvm.org/llvm/bindings/go/build.sh: No such file or directory
guest#system:~/go/src/github.com/go-llvm/llgo$
$ go version
go version go1.8 linux/amd64
$ cmake -version
cmake version 3.8.20170216-gb9229
CMake suite maintained and supported by Kitware (kitware.com/cmake).
guest#system:~/go/src/github.com/go-llvm/llvm$ ./update_llvm.sh
+ llvm_components=all-targets analysis asmparser asmprinter bitreader bitwriter codegen core debuginfo executionengine instrumentation interpreter ipo irreader linker mc mcjit objcarcopts option profiledata scalaropts support target
+ dirname ./update_llvm.sh
+ gollvmdir=.
+ grep run_update_llvm_sh_to_get_revision_ ./llvm_dep.go
+ sed -E -e s/.*run_update_llvm_sh_to_get_revision_([0-9]+.*)/\1/g
+ llvmrev=218171
+ workdir=./workdir
+ llvmdir=./workdir/llvm
+ llvm_builddir=./workdir/llvm_build
+ mkdir -p ./workdir
+ svn co -r 218171 https://llvm.org/svn/llvm-project/llvm/trunk ./workdir/llvm
Checked out revision 218171.
+ mkdir -p ./workdir/llvm_build
+ cmake_flags=../llvm
+ llvm_config=./workdir/llvm_build/bin/llvm-config
+ which ninja
+ test -n /usr/bin/ninja
+ cd ./workdir/llvm_build
+ cmake -G Ninja ../llvm
-- Target triple: x86_64-unknown-linux-gnu
-- Native target architecture is X86
-- Threads enabled.
-- Doxygen disabled.
-- Sphinx disabled.
CMake Warning (dev) at cmake/modules/HandleLLVMOptions.cmake:131 (if):
Policy CMP0054 is not set: Only interpret if() arguments as variables or
keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.
Quoted variables like "C_SUPPORTS_FPIC" will no longer be dereferenced when
the policy is set to NEW. Since the policy is not set the OLD behavior
will be used.
Call Stack (most recent call first):
cmake/modules/HandleLLVMOptions.cmake:148 (add_flag_or_print_warning)
CMakeLists.txt:315 (include)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Building with -fPIC
-- Constructing LLVMBuild project information
-- Targeting AArch64
-- Targeting ARM
-- Targeting CppBackend
-- Targeting Hexagon
-- Targeting Mips
-- Targeting MSP430
-- Targeting NVPTX
-- Targeting PowerPC
-- Targeting R600
-- Targeting Sparc
-- Targeting SystemZ
-- Targeting X86
-- Targeting XCore
-- Configuring done
-- Generating done
-- Build files have been written to: /home/guest/go/src/github.com/go-llvm/llvm/workdir/llvm_build
+ ninja -C ./workdir/llvm_build llvm-config
ninja: Entering directory `./workdir/llvm_build'
[2/2] Linking CXX executable bin/llvm-config
+ ./workdir/llvm_build/bin/llvm-config --libs all-targets analysis asmparser asmprinter bitreader bitwriter codegen core debuginfo executionengine instrumentation interpreter ipo irreader linker mc mcjit objcarcopts option profiledata scalaropts support target
+ sed -e s/-l//g
+ llvm_buildtargets=LLVMOption LLVMObjCARCOpts LLVMMCJIT LLVMRuntimeDyld LLVMLinker LLVMIRReader LLVMipo LLVMVectorize LLVMInterpreter LLVMInstrumentation LLVMExecutionEngine LLVMDebugInfo LLVMBitWriter LLVMAsmParser LLVMXCoreDisassembler LLVMXCoreCodeGen LLVMXCoreDesc LLVMXCoreInfo LLVMXCoreAsmPrinter LLVMX86Disassembler LLVMX86AsmParser LLVMX86CodeGen LLVMX86Desc LLVMX86Info LLVMX86AsmPrinter LLVMX86Utils LLVMSystemZDisassembler LLVMSystemZCodeGen LLVMSystemZAsmParser LLVMSystemZDesc LLVMSystemZInfo LLVMSystemZAsmPrinter LLVMSparcDisassembler LLVMSparcCodeGen LLVMSparcAsmParser LLVMSparcDesc LLVMSparcInfo LLVMSparcAsmPrinter LLVMR600CodeGen LLVMR600Desc LLVMR600Info LLVMR600AsmPrinter LLVMPowerPCDisassembler LLVMPowerPCCodeGen LLVMPowerPCAsmParser LLVMPowerPCDesc LLVMPowerPCInfo LLVMPowerPCAsmPrinter LLVMNVPTXCodeGen LLVMNVPTXDesc LLVMNVPTXInfo LLVMNVPTXAsmPrinter LLVMMSP430CodeGen LLVMMSP430Desc LLVMMSP430Info LLVMMSP430AsmPrinter LLVMMipsDisassembler LLVMMipsCodeGen LLVMMipsAsmParser LLVMMipsDesc LLVMMipsInfo LLVMMipsAsmPrinter LLVMHexagonCodeGen LLVMHexagonAsmPrinter LLVMHexagonDesc LLVMHexagonInfo LLVMCppBackendCodeGen LLVMCppBackendInfo LLVMARMDisassembler LLVMARMCodeGen LLVMARMAsmParser LLVMARMDesc LLVMARMInfo LLVMARMAsmPrinter LLVMAArch64Disassembler LLVMMCDisassembler LLVMAArch64CodeGen LLVMSelectionDAG LLVMAsmPrinter LLVMCodeGen LLVMScalarOpts LLVMProfileData LLVMObject LLVMBitReader LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMTarget LLVMCore LLVMAArch64AsmParser LLVMMCParser LLVMAArch64Desc LLVMAArch64Info LLVMAArch64AsmPrinter LLVMMC LLVMAArch64Utils LLVMSupport
+ ninja -C ./workdir/llvm_build LLVMOption LLVMObjCARCOpts LLVMMCJIT LLVMRuntimeDyld LLVMLinker LLVMIRReader LLVMipo LLVMVectorize LLVMInterpreter LLVMInstrumentation LLVMExecutionEngine LLVMDebugInfo LLVMBitWriter LLVMAsmParser LLVMXCoreDisassembler LLVMXCoreCodeGen LLVMXCoreDesc LLVMXCoreInfo LLVMXCoreAsmPrinter LLVMX86Disassembler LLVMX86AsmParser LLVMX86CodeGen LLVMX86Desc LLVMX86Info LLVMX86AsmPrinter LLVMX86Utils LLVMSystemZDisassembler LLVMSystemZCodeGen LLVMSystemZAsmParser LLVMSystemZDesc LLVMSystemZInfo LLVMSystemZAsmPrinter LLVMSparcDisassembler LLVMSparcCodeGen LLVMSparcAsmParser LLVMSparcDesc LLVMSparcInfo LLVMSparcAsmPrinter LLVMR600CodeGen LLVMR600Desc LLVMR600Info LLVMR600AsmPrinter LLVMPowerPCDisassembler LLVMPowerPCCodeGen LLVMPowerPCAsmParser LLVMPowerPCDesc LLVMPowerPCInfo LLVMPowerPCAsmPrinter LLVMNVPTXCodeGen LLVMNVPTXDesc LLVMNVPTXInfo LLVMNVPTXAsmPrinter LLVMMSP430CodeGen LLVMMSP430Desc LLVMMSP430Info LLVMMSP430AsmPrinter LLVMMipsDisassembler LLVMMipsCodeGen LLVMMipsAsmParser LLVMMipsDesc LLVMMipsInfo LLVMMipsAsmPrinter LLVMHexagonCodeGen LLVMHexagonAsmPrinter LLVMHexagonDesc LLVMHexagonInfo LLVMCppBackendCodeGen LLVMCppBackendInfo LLVMARMDisassembler LLVMARMCodeGen LLVMARMAsmParser LLVMARMDesc LLVMARMInfo LLVMARMAsmPrinter LLVMAArch64Disassembler LLVMMCDisassembler LLVMAArch64CodeGen LLVMSelectionDAG LLVMAsmPrinter LLVMCodeGen LLVMScalarOpts LLVMProfileData LLVMObject LLVMBitReader LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMTarget LLVMCore LLVMAArch64AsmParser LLVMMCParser LLVMAArch64Desc LLVMAArch64Info LLVMAArch64AsmPrinter LLVMMC LLVMAArch64Utils LLVMSupport FileCheck
ninja: Entering directory `./workdir/llvm_build'
ninja: no work to do.
+ ./workdir/llvm_build/bin/llvm-config --version
+ llvm_version=3.6.0svn
+ ./workdir/llvm_build/bin/llvm-config --cppflags
+ llvm_cflags=-I/home/guest/go/src/github.com/go-llvm/llvm/workdir/llvm/include -I/home/guest/go/src/github.com/go-llvm/llvm/workdir/llvm_build/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
+ uname
+ [ Linux == Darwin ]
./update_llvm.sh: 59: [: Linux: unexpected operator
+ ./workdir/llvm_build/bin/llvm-config --ldflags
+ ./workdir/llvm_build/bin/llvm-config --libdir
+ ./workdir/llvm_build/bin/llvm-config --libs all-targets analysis asmparser asmprinter bitreader bitwriter codegen core debuginfo executionengine instrumentation interpreter ipo irreader linker mc mcjit objcarcopts option profiledata scalaropts support target
+ ./workdir/llvm_build/bin/llvm-config --system-libs
+ llvm_ldflags=-L/home/guest/go/src/github.com/go-llvm/llvm/workdir/llvm_build//lib -Wl,-rpath,/home/guest/go/src/github.com/go-llvm/llvm/workdir/llvm_build//lib -lLLVMOption -lLLVMObjCARCOpts -lLLVMMCJIT -lLLVMRuntimeDyld -lLLVMLinker -lLLVMIRReader -lLLVMipo -lLLVMVectorize -lLLVMInterpreter -lLLVMInstrumentation -lLLVMExecutionEngine -lLLVMDebugInfo -lLLVMBitWriter -lLLVMAsmParser -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMXCoreAsmPrinter -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMSystemZDisassembler -lLLVMSystemZCodeGen -lLLVMSystemZAsmParser -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSystemZAsmPrinter -lLLVMSparcDisassembler -lLLVMSparcCodeGen -lLLVMSparcAsmParser -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMSparcAsmPrinter -lLLVMR600CodeGen -lLLVMR600Desc -lLLVMR600Info -lLLVMR600AsmPrinter -lLLVMPowerPCDisassembler -lLLVMPowerPCCodeGen -lLLVMPowerPCAsmParser -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMPowerPCAsmPrinter -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMNVPTXAsmPrinter -lLLVMMSP430CodeGen -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMSP430AsmPrinter -lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMMipsAsmPrinter -lLLVMHexagonCodeGen -lLLVMHexagonAsmPrinter -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMCppBackendCodeGen -lLLVMCppBackendInfo -lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMAArch64Disassembler -lLLVMMCDisassembler -lLLVMAArch64CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMProfileData -lLLVMObject -lLLVMBitReader -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMAArch64AsmParser -lLLVMMCParser -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMMC -lLLVMAArch64Utils -lLLVMSupport -lrt -ldl -ltinfo -latomic -lpthread -lz
+ sed -e s##LLVM_REVISION##218171#g; s##LLVM_CFLAGS##-I/home/guest/go/src/github.com/go-llvm/llvm/workdir/llvm/include -I/home/guest/go/src/github.com/go-llvm/llvm/workdir/llvm_build/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS#g; s##LLVM_LDFLAGS##-L/home/guest/go/src/github.com/go-llvm/llvm/workdir/llvm_build//lib -Wl,-rpath,/home/guest/go/src/github.com/go-llvm/llvm/workdir/llvm_build//lib -lLLVMOption -lLLVMObjCARCOpts -lLLVMMCJIT -lLLVMRuntimeDyld -lLLVMLinker -lLLVMIRReader -lLLVMipo -lLLVMVectorize -lLLVMInterpreter -lLLVMInstrumentation -lLLVMExecutionEngine -lLLVMDebugInfo -lLLVMBitWriter -lLLVMAsmParser -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMXCoreAsmPrinter -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMSystemZDisassembler -lLLVMSystemZCodeGen -lLLVMSystemZAsmParser -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSystemZAsmPrinter -lLLVMSparcDisassembler -lLLVMSparcCodeGen -lLLVMSparcAsmParser -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMSparcAsmPrinter -lLLVMR600CodeGen -lLLVMR600Desc -lLLVMR600Info -lLLVMR600AsmPrinter -lLLVMPowerPCDisassembler -lLLVMPowerPCCodeGen -lLLVMPowerPCAsmParser -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMPowerPCAsmPrinter -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMNVPTXAsmPrinter -lLLVMMSP430CodeGen -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMSP430AsmPrinter -lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMMipsAsmPrinter -lLLVMHexagonCodeGen -lLLVMHexagonAsmPrinter -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMCppBackendCodeGen -lLLVMCppBackendInfo -lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMAArch64Disassembler -lLLVMMCDisassembler -lLLVMAArch64CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMProfileData -lLLVMObject -lLLVMBitReader -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMAArch64AsmParser -lLLVMMCParser -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMMC -lLLVMAArch64Utils -lLLVMSupport -lrt -ldl -ltinfo -latomic -lpthread -lz#g ./llvm_config.go.in
+ printf package llvm\n\nconst Version = "%s"\n 3.6.0svn
guest#system:~/go/src/github.com/go-llvm/llvm/examples$ cd factorial
guest#system:~/go/src/github.com/go-llvm/llvm/examples/factorial$ ls
factorial factorial.go
guest#system:~/go/src/github.com/go-llvm/llvm/examples/factorial$ go build factorial.go
guest#system:~/go/src/github.com/go-llvm/llvm/examples/factorial$ ./factorial
; ModuleID = 'fac_module'
define i32 #fac(i32) {
entry:
%cmptmp = icmp eq i32 %0, 0
br i1 %cmptmp, label %end, label %iffalse
iffalse: ; preds = %entry
%subtmp = add i32 %0, -1
%calltmp = call i32 #fac(i32 %subtmp)
%multmp = mul i32 %calltmp, %0
br label %end
end: ; preds = %entry, %iffalse
%result = phi i32 [ %multmp, %iffalse ], [ 1, %entry ]
ret i32 %result
}
-----------------------------------------
Running fac(10) with JIT...
Result: 3628800
DONE
guest#system:~$ go get llvm.org/llvm.v36/bindings/go/llvm
package llvm.org/llvm.v36/bindings/go/llvm: unrecognized import path "llvm.org/llvm.v36/bindings/go/llvm" (parse https://llvm.org/llvm.v36/bindings/go/llvm?go-get=1: no go-import meta tags ())
guest#system:~$ go get -d llvm.org/llvm.v36/bindings/go/llvm
package llvm.org/llvm.v36/bindings/go/llvm: unrecognized import path "llvm.org/llvm.v36/bindings/go/llvm" (parse https://llvm.org/llvm.v36/bindings/go/llvm?go-get=1: no go-import meta tags ())
$ which llvm-config
/usr/bin/llvm-config
guest#system:~/go/src/github.com/go-llvm/llvm/workdir/llvm_build/bin$ ls
FileCheck llvm-config llvm-lit llvm-tblgen
guest#system:~/go/src/github.com/axw/llgo$ ./update_third_party.sh
github.com/axw/llgo$ ./update_third_party.sh
Cloning into '/tmp/update_third_party.auPNC9/gofrontend'...
remote: Sending approximately 92.68 MiB ...
remote: Counting objects: 3087, done
remote: Finding sources: 100% (69/69)
remote: Total 33940 (delta 26755), reused 33933 (delta 26755)
Receiving objects: 100% (33940/33940), 92.79 MiB | 60.00 KiB/s, done.
Resolving deltas: 100% (26755/26755), done.
Checking connectivity... done.
Note: checking out '81eb6a3f425b2158c67ee32c0cc973a72ce9d6be'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 81eb6a3... runtime: don't overallocate in select code
patching file libgo/runtime/chan.goc
patching file libgo/runtime/chan.h
patching file libgo/runtime/heapdump.c
patching file libgo/runtime/malloc.goc
patching file libgo/runtime/malloc.h
Hunk #1 succeeded at 392 (offset 2 lines).
Hunk #2 succeeded at 403 (offset 2 lines).
Hunk #3 succeeded at 460 (offset 2 lines).
Hunk #4 succeeded at 478 (offset 2 lines).
Hunk #5 succeeded at 507 (offset 2 lines).
patching file libgo/runtime/mcache.c
patching file libgo/runtime/mcentral.c
patching file libgo/runtime/mgc0.c
Hunk #3 succeeded at 1380 (offset 2 lines).
Hunk #4 succeeded at 1390 (offset 2 lines).
Hunk #5 succeeded at 1804 (offset 2 lines).
Hunk #6 succeeded at 2151 (offset 4 lines).
Hunk #7 succeeded at 2428 (offset 5 lines).
Hunk #8 succeeded at 2443 (offset 5 lines).
Hunk #9 succeeded at 2451 (offset 5 lines).
patching file libgo/runtime/mheap.c
patching file libgo/runtime/netpoll.goc
patching file libgo/runtime/proc.c
Hunk #1 succeeded at 326 (offset 24 lines).
Hunk #2 succeeded at 809 (offset 100 lines).
Hunk #3 succeeded at 820 (offset 100 lines).
Hunk #4 succeeded at 847 (offset 100 lines).
Hunk #5 succeeded at 855 (offset 100 lines).
Hunk #6 succeeded at 864 (offset 100 lines).
Hunk #7 succeeded at 881 (offset 100 lines).
Hunk #8 succeeded at 894 (offset 100 lines).
Hunk #9 succeeded at 933 (offset 100 lines).
Hunk #10 succeeded at 953 (offset 100 lines).
Hunk #11 succeeded at 987 (offset 100 lines).
Hunk #12 succeeded at 1011 (offset 100 lines).
Hunk #13 succeeded at 1452 (offset 106 lines).
Hunk #14 succeeded at 1481 (offset 106 lines).
Hunk #15 succeeded at 1525 (offset 106 lines).
Hunk #16 succeeded at 1618 (offset 106 lines).
Hunk #17 succeeded at 1673 (offset 106 lines).
Hunk #18 succeeded at 1709 (offset 106 lines).
Hunk #19 succeeded at 1730 (offset 106 lines).
Hunk #20 succeeded at 1749 (offset 106 lines).
Hunk #21 succeeded at 1794 (offset 106 lines).
Hunk #22 succeeded at 1832 (offset 106 lines).
Hunk #23 succeeded at 1928 (offset 106 lines).
Hunk #24 succeeded at 2031 (offset 106 lines).
Hunk #25 succeeded at 2159 (offset 106 lines).
Hunk #26 succeeded at 2184 (offset 106 lines).
Hunk #27 succeeded at 2192 (offset 106 lines).
Hunk #28 succeeded at 2484 (offset 119 lines).
Hunk #29 succeeded at 2595 (offset 119 lines).
Hunk #30 succeeded at 2627 (offset 119 lines).
Hunk #31 succeeded at 2657 (offset 119 lines).
Hunk #32 succeeded at 2682 (offset 119 lines).
Hunk #33 succeeded at 2826 (offset 119 lines).
Hunk #34 succeeded at 2906 (offset 126 lines).
Hunk #35 succeeded at 3044 (offset 126 lines).
Hunk #36 succeeded at 3080 (offset 126 lines).
Hunk #37 succeeded at 3112 (offset 126 lines).
Hunk #38 succeeded at 3268 (offset 126 lines).
Hunk #39 succeeded at 3422 (offset 126 lines).
patching file libgo/runtime/runtime.h
patching file libgo/runtime/sema.goc
patching file libgo/runtime/sigqueue.goc
patching file libgo/runtime/time.goc
patching file libgo/Makefile.am
Hunk #1 succeeded at 4139 (offset 401 lines).
Hunk #2 succeeded at 4246 (offset 409 lines).
patching file libgo/Makefile.in
Hunk #1 succeeded at 2433 (offset 221 lines).
Hunk #2 succeeded at 2540 (offset 229 lines).
patching file libgo/go/runtime/mfinal_test.go
Hunk #1 succeeded at 65 (offset 3 lines).
cp: cannot stat '../../cmake/config.guess': No such file or directory
how can fix?

How to build cmake 3.1.3 using clang 3.6.0 and libc++?

I'm trying to build cmake 3.1.3 using clang and its own c++ library, i.e:
export CC=clang
export CXX=clang++
export CXXFLAGS="-std=c++11 -stdlib=libc++"
export LDFLAGS="-lc++ -lc++abi"
followed by
./bootstrap
However, this does not work due to the way the bootstrap script tests the CXX compiler. If I hack the bootstrap file and add the LDFLAGS to the CXX test I can start to compile cmake. However, once I reach the bootstrap stage, the compile cmake binary is broken. What am I doing wrong?
Using Angew's idea and trying to compile with the existing cmake installation actually gets you a bit farther: If you use almost the same exports as above:
export CC=clang
export CXX=clang++
export CXXFLAGS="-std=c++11 -stdlib=libc++"
export LDFLAGS="-L${COMPILERROOT}/lib -lc++ -lc++abi"
and a little sed to get around a weird compilation error (assuming you are in a different build directory and you extracted the cmake sources to the directory ../cmake from the current one)
sed -i s/kwsys_ios::hex/cmsys_ios::istringstream::hex/g ../cmake/Source/kwsys/SystemInformation.cxx
sed -i s/kwsys_ios::dec/cmsys_ios::istringstream::dec/g ../cmake/Source/kwsys/SystemInformation.cxx
You can then compile cmake via:
cmake ../cmake/ -DCMAKE_INSTALL_PREFIX=${INSTALLDIR}
make -j${NPROC}
make install
It still crashed for example if I try to cmake a Cern ROOT6 install:
This warning is for project developers. Use -Wno-dev to suppress it.
uncaught_exception not yet implemented
Program received signal SIGABRT, Aborted.
0x00007ffff6e495e9 in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x00007ffff6e495e9 in raise () from /lib64/libc.so.6
#1 0x00007ffff6e4acf8 in abort () from /lib64/libc.so.6
#2 0x00007ffff7b755a5 in std::uncaught_exception() () from /home/balzer/middleware/software/clang/3.6.0/lib/libc++.so.1
#3 0x00007ffff7ba80fd in std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::~sentry() () from /home/balzer/middleware/software/clang/3.6.0/lib/libc++.so.1
#4 0x0000000000531561 in std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) ()
#5 0x0000000000530c8c in std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<< <std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) ()
#6 0x000000000052fccb in cmakemainMessageCallback(char const*, char const*, bool&, void*) ()
#7 0x00000000007527c9 in cmSystemTools::Message(char const*, char const*) ()
#8 0x000000000085c934 in cmake::IssueMessage(cmake::MessageType, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cmListFileBacktrace const&) ()
#9 0x000000000062a756 in cmMakefile::IssueMessage(cmake::MessageType, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const ()
#10 0x00000000009c56cb in cmConditionEvaluator::GetDefinitionIfUnquoted(cmExpandedCommandArgument const&) const ()
#11 0x00000000009c57fd in cmConditionEvaluator::GetVariableOrString(cmExpandedCommandArgument const&) const ()
#12 0x00000000009c0600 in cmConditionEvaluator::HandleLevel2(std::__1::list<cmExpandedCommandArgument, std::__1::allocator<cmExpandedCommandArgument> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, cmake::MessageType&) ()
#13 0x00000000009bce3b in cmConditionEvaluator::IsTrue(std::__1::vector<cmExpandedCommandArgument, std::__1::allocator<cmExpandedCommandArgument> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, cmake::MessageType&) ()
#14 0x00000000009bdd5e in cmConditionEvaluator::HandleLevel0(std::__1::list<cmExpandedCommandArgument, std::__1::allocator<cmExpandedCommandArgument> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, cmake::MessageType&) ()
#15 0x00000000009bcd91 in cmConditionEvaluator::IsTrue(std::__1::vector<cmExpandedCommandArgument, std::__1::allocator<cmExpandedCommandArgument> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, cmake::MessageType&) ()
#16 0x00000000009d902b in cmIfCommand::InvokeInitialPass(std::__1::vector<cmListFileArgument, std::__1::allocator<cmListFileArgument> > const&, cmExecutionStatus&) ()
#17 0x000000000062b4d6 in cmMakefile::ExecuteCommand(cmListFileFunction const&, cmExecutionStatus&) ()
#18 0x000000000098ffb1 in cmForEachFunctionBlocker::IsFunctionBlocked(cmListFileFunction const&, cmMakefile&, cmExecutionStatus&) ()
#19 0x000000000062c5cb in cmMakefile::IsFunctionBlocked(cmListFileFunction const&, cmExecutionStatus&) ()
#20 0x000000000062b21c in cmMakefile::ExecuteCommand(cmListFileFunction const&, cmExecutionStatus&) ()
#21 0x0000000000630242 in cmMakefile::ReadListFile(char const*, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, bool) ()
#22 0x00000000005cbad4 in cmLocalGenerator::ReadInputFile() ()
#23 0x00000000005cb437 in cmLocalGenerator::Configure() ()
#24 0x0000000000ca2af8 in cmLocalUnixMakefileGenerator3::Configure() ()
#25 0x0000000000bf3df6 in cmGlobalGenerator::Configure() ()
#26 0x0000000000c44edd in cmGlobalUnixMakefileGenerator3::Configure() ()
#27 0x000000000084c49e in cmake::ActualConfigure() ()
#28 0x0000000000849b24 in cmake::Configure() ()
#29 0x0000000000850efa in cmake::Run(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, bool) ()
#30 0x000000000052f665 in do_cmake(int, char const* const*) ()
#31 0x000000000052c149 in main ()
However, if I add the -Wno-dev option to the cmake call it works fine.

GCC linker ignores symbols in a .a library that I have confirmed are present

I have a really perplexing problem in GCC.
I get the following error:
gcc -Wall -Werror -L/Users/red_angel/chorebox_sys/lib -o products/chbc2c -lchorebox ofiles/main.o
Undefined symbols for architecture x86_64:
"_chbclib_flushout", referenced from:
_main in main.o
"_chorebox_argc", referenced from:
_chorebox_command_line in libchorebox.a(chorebox_command_line.o)
"_chorebox_argv", referenced from:
_chorebox_command_line in libchorebox.a(chorebox_command_line.o)
"_chorebox_env", referenced from:
_chorebox_command_line in libchorebox.a(chorebox_command_line.o)
"_mn_command_options", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [products/chbc2c] Error 1
What's wrong with this error? I have confirmed that the _chorebox_argc symbol is indeed present in "libchorebox.a".
I confirmed it by running the command:
nm /Users/red_angel/chorebox_sys/lib/libchorebox.a | cat -n | chodo -_chorebox_argc flip
As the "chodo" command is an command I wrote that you may not be familiar - I will explain what it does. It reads from Standard Input, and forward to Standard Output every line that matches the search pattern. In this case (to make a long story short) it outputs every line containing the "_chorebox_argc" string.
I get the following output:
3 0000000000000004 C _chorebox_argc
55 U _chorebox_argc
To get a closer look at the relevant part of the file, I type the same command, only this time omitting the "chodo" command at the end of the piped series of commands --- and hereby will copy/paste to you the relevant part of that file:
1
2 /Users/red_angel/chorebox_sys/lib/libchorebox.a(vars.o):
3 0000000000000004 C _chorebox_argc
4 0000000000000008 C _chorebox_argv
5 0000000000000008 C _chorebox_env
6
7 /Users/red_angel/chorebox_sys/lib/libchorebox.a(chorebox_mlc.o):
8 00000000000000c8 s EH_frame0
9 0000000000000075 s L_.str
10 U ___stderrp
11 U _chorebox_argv
12 0000000000000000 T _chorebox_mlc
13 00000000000000e0 S _chorebox_mlc.eh
14 U _exit
15 U _fflush
16 U _fprintf
17 U _malloc
18
19 /Users/red_angel/chorebox_sys/lib/libchorebox.a(chorebox_apend_string.o):
20 0000000000000078 s EH_frame0
21 0000000000000000 T _chorebox_apend_string
22 0000000000000090 S _chorebox_apend_string.eh
23 U _chorebox_join_string
24 U _free
25
Needless to say ---- the symbol is definitely present in the "libchorebox.a" file ----- so why is the GCC linker complaining that it is not found?
After some discussion in chat, we discovered that the problem lay in 'common' definitions. A simplified version of the code causing trouble follows. The system is Mac OS X (Mavericks and Yosemite).
With common definitions only
vars.h
extern int chorebox_argc;
extern char **chorebox_argv;
extern char **chorebox_envp;
vars.c
#include "vars.h"
int chorebox_argc;
char **chorebox_argv;
char **chorebox_envp;
main.c
#include "vars.h"
int main(int argc, char **argv, char **envp)
{
chorebox_argc = argc;
chorebox_argv = argv;
chorebox_envp = envp;
return argc;
}
Compilation 1
$ gcc -c vars.c
$ nm vars.o
0000000000000004 C _chorebox_argc
0000000000000008 C _chorebox_argv
0000000000000008 C _chorebox_envp
$ ar rv libvars.a vars.o
ar: creating archive libvars.a
a - vars.o
$ ranlib libvars.a
warning: ranlib: warning for library: libvars.a the table of contents is
empty (no object file members in the library define global symbols)
$ gcc -c main.c
$ gcc -o program main.o vars.o
$ gcc -o program main.o -L. -lvars
Undefined symbols for architecture x86_64:
"_chorebox_argc", referenced from:
_main in main.o
"_chorebox_argv", referenced from:
_main in main.o
"_chorebox_envp", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
$
Note the C in the output from nm. That indicates a 'common' definition of the variables. It isn't enough, on its own, to make them into variable definitions — witness the message from ranlib.
I'm not sure if this is new behaviour in Mac OS X or not. However, it seems that having a source file that only defines uninitialized variables isn't sufficient when the variables are defined in a library, though it is sufficient when the object file is linked directly.
With variable definitions
vardefs.c
#include "vars.h"
int chorebox_argc = 0;
char **chorebox_argv = 0;
char **chorebox_envp = 0;
This has explicitly initialized versions of the variables. The initializer values are the same as the default values, but the explicit initialization makes all the difference.
Compilation 2
$ rm libvars.a
$ gcc -c vardefs.c
$ ar rv libvars.a vardefs.o
ar: creating archive libvars.a
a - vardefs.o
$ gcc -o program main.o -L. -lvars
$
The explicitly initialized variables are picked up from the library without problem.
With one variable definition
vars.h
extern int chorebox_argc;
extern char **chorebox_argv;
extern char **chorebox_envp;
extern int make_believe;
vars.c
#include "vars.h"
int chorebox_argc;
char **chorebox_argv;
char **chorebox_envp;
int make_believe = 59;
main.c
#include "vars.h"
int main(int argc, char **argv, char **envp)
{
chorebox_argc = argc;
chorebox_argv = argv;
chorebox_envp = envp;
make_believe = 1;
return argc;
}
Compilation 3
$ gcc -c vars.c
$ ar rv libvars.a vars.o
ar: creating archive libvars.a
a - vars.o
$ nm vars.o
0000000000000004 C _chorebox_argc
0000000000000008 C _chorebox_argv
0000000000000008 C _chorebox_envp
0000000000000000 D _make_believe
$ gcc -c main.c
$ gcc -o program main.o -L. -lvars
$
Note that adding the initialized make_believe is sufficient to pull the object file from the library, and the common definitions for the other variables are then sufficient to satisfy the linker.
Lessons
Although the linking order was part of the problem, it was not the whole problem.
Providing uninitialized global variables in a library doesn't always work, especially if there are no other definitions in the same source file.
As I noted in the chat, it is generally not a good idea to provide direct access to global variables. It would be better to provide functional interfaces to access (get and set) the variables.
Put the -l option after the file that needs it (ofiles/main.o)
See this question for more information on link order.

g++ "value temporarily unavailable, due to optimizations"

I'm getting some "value temporarily unavailable, due to optimizations" problems, but I am compiling with debug enabled, as far as I know.
I.e. I'm using -g -O0 -fno-inline flags, so I'm not sure why is this still happening. Is it some flag I missed?
Compiler is g++-mp-4.6 (GCC) 4.6.3, OS is OSX 10.6 Darwin Palace-of-the-Nine-Moons.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
Full compile options are g++-mp-4.6 -Wall -Werror -Wno-unused -g -O0 -fno-inline -I/usr/local/include -I../allig -std=c++0x -c src/Toolbox.cpp -o o/Toolbox.o for every file.
gdb session:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000021
[Switching to process 23874]
0x0000000100035d64 in al_get_bitmap_width ()
(gdb) bt
#0 0x0000000100035d64 in al_get_bitmap_width ()
#1 0x0000000100005e47 in Icon::resize (this=0x101244530, w=<value temporarily unavailable, due to optimizations>, h=<value temporarily unavailable, due to optimizations>) at ../allig/Icon.cpp:24
#2 0x0000000100005e1f in Icon::create_icon (this=0x101244530, _icon_size=<value temporarily unavailable, due to optimizations>) at ../allig/Icon.cpp:20
#3 0x000000010000ae24 in Icontainer::add_icon (this=0x101244210, tt=0x101244530) at ../allig/Icontainer.cpp:18
#4 0x0000000100002d58 in _al_mangled_main (argc=1, argv=0x7fff5fbff600) at src/mapedit.cpp:202
#5 0x000000010009ff17 in +[AllegroAppDelegate app_main:] ()
#6 0x00007fff82d45114 in __NSThread__main__ ()
#7 0x00007fff81f4afd6 in _pthread_start ()
#8 0x00007fff81f4ae89 in thread_start ()
(gdb) up
#1 0x0000000100005e47 in Icon::resize (this=0x101244530, w=<value temporarily unavailable, due to optimizations>, h=<value temporarily unavailable, due to optimizations>) at ../allig/Icon.cpp:24
24 ow=al_get_bitmap_width(icon);
Current language: auto; currently c++
[...]
(gdb) up
#2 0x0000000100005e1f in Icon::create_icon (this=0x101244530, _icon_size=<value temporarily unavailable, due to optimizations>) at ../allig/Icon.cpp:20
20 resize(_icon_size,_icon_size);
(gdb) print _icon_size
$2 = <value temporarily unavailable, due to optimizations>
(gdb) up
#3 0x000000010000ae24 in Icontainer::add_icon (this=0x101244210, tt=0x101244530) at ../allig/Icontainer.cpp:18
18 tt->create_icon(icon_size);
(gdb) print icon_size
$3 = 32 ' '
(gdb) quit
code snippets:
void Icon::resize (unsigned char w, unsigned char h) {
unsigned short ow,oh;
ow=al_get_bitmap_width(icon);
up
void Icon::create_icon (unsigned char _icon_size) {
resize(_icon_size,_icon_size);
}
up
int Icontainer::add_icon (Icon *tt) {
int ret=icons.size();
tt->tool=TOOL_TILE;
tt->create_icon(icon_size);
finally here the icon size was available.

Resources