Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 330249

Summary: Debug configuration doesn't compile with gcc 4.5.1
Product: [Tools] CDT Reporter: gallo <gallo33>
Component: cdt-buildAssignee: cdt-build-inbox <cdt-build-inbox>
Status: RESOLVED NOT_ECLIPSE QA Contact: Andrew Gvozdev <angvoz.dev>
Severity: normal    
Priority: P3 CC: aegges, cdtdoug, damir.franusic, hedayat.fwd+eclipsebz, malaperle, mtj
Version: 8.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description gallo CLA 2010-11-15 09:27:47 EST
Build Identifier: 20100917-0705

Every executable project in debug configuration with gcc 4.5.1 (both C and C++) generates the following error:
cc1: error: to generate dependencies you must specify either -M or -MM

Reproducible: Always

Steps to Reproduce:
1. New->Project->C Project
2. then choose Executable->Hello World C Project
3. then Build Configuration -> Build Selected -> Debug
Comment 1 Marc-André Laperle CLA 2010-11-16 19:51:59 EST
I can't reproduce this, what is the command generated?

I copied the command from the Console view and tried it outside of Eclipse and it also worked:

~/workspace/hello/Debug$ ~/gcc-4.5.1-build/bin/gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/hello.d" -MT"src/hello.d" -o"src/hello.o" "../src/hello.c"

then

~/workspace/hello/Debug$ ~/gcc-4.5.1-build/bin/gcc  -o"hello"  ./src/hello.o 

am I doing something wrong?
Comment 2 gallo CLA 2010-11-17 08:35:50 EST
That's my console output:
**** Build of configuration Debug for project Hello ****

make all 
Building file: ../src/Hello.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/Hello.d" -MT"src/Hello.d" -o"src/Hello.o" "../src/Hello.cpp"
cc1plus: error: to generate dependencies you must specify either -M or -MM
make: *** [src/Hello.o] Errore 1

and it's the same with C compiler in place of g++.
You can also take a look at the following discussion:
http://www.eclipse.org/forums/index.php?t=msg&th=199435&start=0&S=0d1c0aaf6c3cb4fb0a53c382086a5c62
What's your gcc version? This error happened to me when I started using 4.5.1 version.
Comment 3 Marc-André Laperle CLA 2010-11-17 12:49:14 EST
(In reply to comment #2)
> What's your gcc version? This error happened to me when I started using 4.5.1
> version.

I compiled gcc 4.5.1 from source and also tried the gcc-4.5 package in Ubuntu 10.10 and I removed gcc-4.4 to make sure it's not using it. How did you get yours?
Comment 4 gallo CLA 2010-11-19 03:43:27 EST
My distribution is Fedora 14 x86_64 and that's my gcc version:
$ gcc --version
gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Let me know if you need to know something else.
Comment 5 Andrew Gvozdev CLA 2010-11-22 11:05:03 EST
There was a change recently where space has been added to options like [-MF "src/Hello.d"]. Not sure if it applies here though. Marc, are you using CDT from HEAD?
Comment 6 Marc-André Laperle CLA 2010-11-22 12:56:21 EST
I was testing with 8.0.0.201011161204 but I just tried 7.0.1 and it still works on Ubuntu. I will test on Fedora tonight.
Comment 7 Marc-André Laperle CLA 2010-11-23 02:15:13 EST
I can't reproduce this on Fedora 14 i686 and Fedora 14 x86_64. 

Can you try this in command line?

g++ -MMD Hello.cpp

and if this works, the full command line

g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/Hello.d"
-MT"src/Hello.d" -o"src/Hello.o" "../src/Hello.cpp"

in your project/Debug folder?

Here's what I have:

Linux fedora 2.6.35.6-48.fc14.x86_64
gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4).
make 3.82-3.fc14
Eclipse IDE for C/C++ Linux Developers (CDT 7.0.1) with -XX:-UseCompressedOops workaround found here
https://bugzilla.redhat.com/show_bug.cgi?id=647737#c31
and I also tried the package
eclipse-cdt-1:7.0.1-2.fc14 (x86_64)
Comment 8 gallo CLA 2010-11-23 08:47:44 EST
(In reply to comment #7)
I tried both your request and the first works but the second keeps throwing the same error.
Here some additional info about my system:
make-3.82-3.fc14.x86_64
and I tried both "original eclipse helios" and the eclipse built for fedora.
Let me know if you need to know something more-
Comment 9 damir.franusic CLA 2010-11-24 12:36:37 EST
I am also having the same problem on Fedora 14 64bit...

g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/SPcap.d" -MT"src/SPcap.d" -o"src/SPcap.o" "../src/SPcap.cpp"
cc1plus: error: to generate dependencies you must specify either -M or -MM
Comment 10 Marc CLA 2010-11-26 23:45:31 EST
Having the same problem with gcc 4.5.1 under Fedora 14

> gcc --version
gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)

I can confirm, that some blanks should fix the problem:

> g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/CppHelloWorld.d" -MT"src/CppHelloWorld.d" -o"src/CppHelloWorld.o" "../src/CppHelloWorld.cpp"

cc1plus: error: to generate dependencies you must specify either -M or -MM

whereas

> g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF "src/CppHelloWorld.d" -MT "src/CppHelloWorld.d" -o"src/CppHelloWorld.o" "../src/CppHelloWorld.cpp"

works.

(Note, that following gcc's initial message by adding either -M or -MM leads to an empty object file.)
Comment 11 Hedayat Vatankhah CLA 2010-11-28 08:21:57 EST
Apparently there is something wrong with ccache. If you disable ccache (add CCACHE_DISABLE=1 environment variable to eclipse project settings or run 'export CCACHE_DISABLE=1 in bash and then run make all in the Debug directory), you won't see this error.
Comment 13 Andrew Gvozdev CLA 2010-11-28 18:18:10 EST
(In reply to comment #12)
> Fixed in ccache 3.1.3:
Closing this bug then. Note that recent CDT 8.0 builds do not have this problem because now spaces are added to options, see bug 232373.