Skip to content

Instantly share code, notes, and snippets.

@stefantalpalaru
Created May 30, 2018 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefantalpalaru/3e984cf56c2eea462ae761143e0d0dfd to your computer and use it in GitHub Desktop.
Save stefantalpalaru/3e984cf56c2eea462ae761143e0d0dfd to your computer and use it in GitHub Desktop.
GCC precompiled header bug on bdver2 with -march=native
#include "stdafx.h"
int main(int argc, char**argv)
{
std::string s = "Hi";
std::cout << s << std::endl;
return 0;
}
#!/bin/bash
set -euo pipefail
CXXFLAGS="-O3 -march=native -pipe -Winvalid-pch"
# on an AMD FX-8320E this appears, about 40% of the time, with both gcc-7.3.0 and gcc-8.1.0, on Gentoo ~amd64:
#a.cpp:1:20: warning: stdafx.h.gch: created and used with differing settings of '-mlwp'
# #include "stdafx.h"
# ^
#CXXFLAGS="-O3 -march=bdver2 -pipe -Winvalid-pch"
# no warning with an explicit -march
rm -f stdafx.h.gch a
g++ $CXXFLAGS -c stdafx.h -o stdafx.h.gch
g++ $CXXFLAGS -o a a.cpp
#include <string>
#include <iostream>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment