error with gcc 5 for varargs function: suffix or operands invalid for `movq'

試著忘記壹切 提交于 2019-12-11 10:51:40

问题


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.



来源:https://stackoverflow.com/questions/34457801/error-with-gcc-5-for-varargs-function-suffix-or-operands-invalid-for-movq

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!