ambrop72 / aprinter

3D printer firmware written in C++
Other
144 stars 42 forks source link

Crash when building with debug symbols. #24

Closed Graeme84 closed 8 years ago

Graeme84 commented 8 years ago

I tried to build the software with debug symbols and GCC crashed. Any suggestions for how to do this? I have also tried with clang and had a similar result.

Bug report to GCC - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70599

ambrop72 commented 8 years ago

Hey,

Thanks for interest in my software, and the bug report!

I have successfully built with debug symbols with clang. Your error message on the bug report says Killed which means you ran out of memory, rather than an actual crash.

Maybe you need more memory? Are you using 32-bit userspace? This won't work well due to limited virtual memory. Since we build the compiler from source using Nix-expressions, if you use 64-bit Nix stuff, you'll get a 64-bit compiler, and then you just need enough RAM ;)

Can you send me your aprinter config file so I can try building?

ambrop72 commented 8 years ago

I will also try to do some changes in the code that will reduce the number of template parameters in symbol names.

Graeme84 commented 8 years ago

Config file is here - http://pastebin.com/pQxRQETX

I have 8 GB memory and I have installed 64 bit Nix (using the file command on the GCC compiler confirms it is a 64-bit executable). I also have 8 GB of swap space (maybe this is not being used properly, I will check). Either way, this is a lot of resource to compile something that is ~30k lines after preprocessing!

I will have another try with clang too.

Thanks :)

Graeme84 commented 8 years ago

Clang failed again. It didn't use up all of my memory before it bailed, unlike GCC. Here is the output:

Compiling C++ files
+ /nix/store/pi4avl7sjbrb1linsm0d50wn0ayn9xz6-clang-arm-embedded-3.7.0/bin/arm-none-eabi-clang -x c++ -c -mcpu=cortex-m3 -mthumb -fno-math-errno -fno-trapping-math -fshort-enums -fno-rtti -fno-exceptions -DNDEBUG -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -I. -Wfatal-errors -Wno-absolute-value -Wno-undefined-internal -Wno-deprecated-register -ffunction-sections -fdata-sections -DAPRINTER_BROKEN_FABS -Wno-unsequenced -D__SAM3X8E__ -DHEAP_SIZE=16384 -DBOARD=43 -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/utils/cmsis/sam3x/include -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/utils/cmsis/sam3x/source/templates -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/utils -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/utils/preprocessor -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/utils/header_files -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/boards -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/drivers/pmc -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/drivers/pio -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/drivers/dmac -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/drivers/emac -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/drivers/rstc -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/utils -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/services/usb -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/services/usb/udc -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/services/clock -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/services/sleepmgr -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/services/ioport -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/services/usb/class/cdc -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/services/usb/class/cdc/device -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/boards -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/thirdparty/CMSIS/Include -I/nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework -I aprinter/platform/at91sam3x -DUSB_SERIAL -std=c++11 -fno-access-control -ftemplate-depth=1024 -g ./main/aprinter-nixbuild.cpp -o ./build/aprinter-nixbuild.o
arm-none-eabi-clang: /tmp/nix-build-clang-arm-embedded-3.7.0.drv-0/llvm-3.7.0.src/lib/IR/Metadata.cpp:160: void llvm::ReplaceableMetadataImpl::replaceAllUsesWith(llvm::Metadata*): Assertion `!(MD && isa<MDNode>(MD) && cast<MDNode>(MD)->isTemporary()) && "Expected non-temp node"' failed.
0  arm-none-eabi-clang 0x0000000002690445 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  arm-none-eabi-clang 0x000000000268f689
2  libpthread.so.0     0x00007fe1dc31dc20
3  libc.so.6           0x00007fe1db57b297 gsignal + 55
4  libc.so.6           0x00007fe1db57c69a abort + 362
5  libc.so.6           0x00007fe1db5743e6
6  libc.so.6           0x00007fe1db574492
7  arm-none-eabi-clang 0x00000000025247bb
8  arm-none-eabi-clang 0x0000000000907155 clang::CodeGen::CGDebugInfo::finalize() + 677
9  arm-none-eabi-clang 0x0000000000986021 clang::CodeGen::CodeGenModule::Release() + 609
10 arm-none-eabi-clang 0x00000000008dfcee
11 arm-none-eabi-clang 0x0000000000b14255 clang::ParseAST(clang::Sema&, bool, bool) + 709
12 arm-none-eabi-clang 0x00000000008e0acb clang::CodeGenAction::ExecuteAction() + 59
13 arm-none-eabi-clang 0x00000000006f48e6 clang::FrontendAction::Execute() + 502
14 arm-none-eabi-clang 0x00000000006cc061 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 353
15 arm-none-eabi-clang 0x00000000006b0cd3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2099
16 arm-none-eabi-clang 0x00000000006a7fe8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 2936
17 arm-none-eabi-clang 0x0000000000685bd1 main + 1569
18 libc.so.6           0x00007fe1db568985 __libc_start_main + 245
19 arm-none-eabi-clang 0x00000000006a6bb9 _start + 41
Stack dump:
0.  Program arguments: /nix/store/pi4avl7sjbrb1linsm0d50wn0ayn9xz6-clang-arm-embedded-3.7.0/bin/arm-none-eabi-clang -cc1 -triple thumbv7m-none--eabi -emit-obj -mrelax-all -disable-free -main-file-name aprinter-nixbuild.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -masm-verbose -mconstructor-aliases -target-cpu cortex-m3 -target-feature +soft-float-abi -target-abi aapcs -mfloat-abi soft -target-linker-version 2.23.1 -g -dwarf-column-info -ffunction-sections -fdata-sections -coverage-file /home/graeme/3D_Printer/aprinter/./build/aprinter-nixbuild.o -resource-dir /nix/store/pi4avl7sjbrb1linsm0d50wn0ayn9xz6-clang-arm-embedded-3.7.0/bin/../lib/clang/3.7.0 -D NDEBUG -D __STDC_LIMIT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_CONSTANT_MACROS -D APRINTER_BROKEN_FABS -D __SAM3X8E__ -D HEAP_SIZE=16384 -D BOARD=43 -D USB_SERIAL -I . -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/utils/cmsis/sam3x/include -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/utils/cmsis/sam3x/source/templates -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/utils -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/utils/preprocessor -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/utils/header_files -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/boards -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/drivers/pmc -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/drivers/pio -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/drivers/dmac -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/drivers/emac -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/sam/drivers/rstc -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/utils -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/services/usb -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/services/usb/udc -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/services/clock -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/services/sleepmgr -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/services/ioport -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/services/usb/class/cdc -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/services/usb/class/cdc/device -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/common/boards -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework/thirdparty/CMSIS/Include -I /nix/store/5zqyagbnfaxrqizldzy5rd53cdhb517n-atmel-software-framework -I aprinter/platform/at91sam3x -Wfatal-errors -Wno-absolute-value -Wno-undefined-internal -Wno-deprecated-register -Wno-unsequenced -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/graeme/3D_Printer/aprinter -ftemplate-depth 1024 -ferror-limit 19 -fmessage-length 271 -mstackrealign -fno-access-control -fno-rtti -fshort-enums -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -o ./build/aprinter-nixbuild.o -x c++ ./main/aprinter-nixbuild.cpp 
1.  <eof> parser at end of file
2.  Per-file LLVM IR generation
arm-none-eabi-clang: fatal error: unable to execute command: Aborted (core dumped)
clang version 3.7.0 (tags/RELEASE_370/final)
Target: arm-none--eabi
Thread model: posix
ambrop72 commented 8 years ago

Yeah, I've seen this recently. Looks like a real clang/llvm bug. I'm in the process of trying to reduce the symbol sizes, I've managed some reduction yet but more is needed. Note that improvements are/will be in the web-interface branch.

ambrop72 commented 8 years ago

I've managed to reduce the size of "nm --demangle aprinter-nixbuild.elf" considerably but debug builds with gcc still take all my memory. I'll try more but I'm not so sure anymore if this actually helps.

Anyway I'm currently trying a patch for the LLVM bug we're hitting. LLVM takes long to build though...

ambrop72 commented 8 years ago

Hey, The patch fixes it. I've already included it in the web-interface branch.

Graeme84 commented 8 years ago

Wow, that's awesome. Thanks for all the help.

I tried adding some extra swap space and building with GCC. Swap usage increased to about 16.7 GB, then my computer froze. Whatever GCC is doing, it isn't very memory efficient!

How stable is your web-interface branch just now? Do you recommend it for general use?

ambrop72 commented 8 years ago

Hey, Yes the web-interface branch should be fine.