-->

error with gcc 5 for varargs function: suffix or o

2019-02-28 23:52发布

问题:

When trying to install OpenMPI the .configure filed failed in the section checking for ISO C99 ability of the selected compiler.

Puzzled as gcc of course has both the std=gnu99 and std=c99 option, I pruning the 20,000 lines configure file to isolate the offending section. In the end I traced it back to gcc 5 not compiling variable argument functions.

The below code generates the "suffix or operands invalid for `movq'" error, which is the root cause of the .configure file failing.

(The step-by-step installation for OpenMPI I followed is here https://wiki.helsinki.fi/display/HUGG/Installing+Open+MPI+on+Mac+OS+X)

Anyone has seen this and knows how to fix it?

//-----------------------------------------------------------------------------
// This fails to compile with gcc 5.3
//
// Command: gcc test4.c
//
// Error is: 
//  /var/folders/4s/gkkpz000gn/T//ccAraq59.s:47:suffix or operands invalid for `movq'
//  /var/folders/4s/gkg0r000gn/T//ccAraq59.s:52:suffix or operands invalid for `movq'
//
// gcc version is 5.3.0:
//
// $ gcc --version
// gcc (GCC) 5.3.0
// Copyright (C) 2015 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.
//
//-----------------------------------------------------------------------------


// Check varargs
static void
test_varargs (const char *format, ...)
{
}


//--------------------------------------------------------------
//                         MAIN {}   
//--------------------------------------------------------------

 int
 main ()
 {

    //====================================================
    // Check varargs.
    // test_varargs ("s", "string");            //WORKS
    // test_varargs ("d' ", 65);                //WORKS
    // test_varargs ("s, d' ", "string", 65);   //WORKS

    test_varargs ("f .", 34.234);                       // FAILS!!!
    test_varargs ("s, d' f .", "string", 65, 34.234);   //ALSO FAILS
    //====================================================


   return 0;
 }

回答1:

TLDR: conflict between brew and XCode gcc installs.

I ended up uninstalling all gcc versions installed, deleting g++, deleting all dangling links left over. Next I upgraded from XCode 6 to 7 and used the gcc version coming with it. This fixed the above problem. Deleting all dangling symlinks and the unziped tar-ball of OpenMPI and then re-unzipping allowed the OpenMPI to be installed without a hitch. cd ./examples, make all, mpirun -np 4 hello_c worked and we have a happy MPI installation.



标签: gcc openmpi gcc5