http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56357
Bug #: 56357 Summary: [4.8 Regression] missing symbol references for libgomp when using -flto -fopenmp on mingw32 Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgomp AssignedTo: unassig...@gcc.gnu.org ReportedBy: daniel.f.sta...@freenet.de CC: ja...@gcc.gnu.org The combination of -flto and -fopenmp is broken for mingw32 in r196092. #define ARRAY_SIZE 10 int main() { int i; volatile int a[ARRAY_SIZE]; #pragma omp parallel for private(a) for (i = 0; i < ARRAY_SIZE; i++) { a[i] += i; } return 0; } This code works fine with "gcc -fopenmp gcc-lto-gomp.c" but results in errors for "gcc -fopenmp -flto gcc-lto-gomp.c". Adding -lgomp does not solves this. Error output: C:\Users\Me\AppData\Local\Temp\cccobKR8.ltrans0.ltrans.o:cccobKR8.ltrans0.o:(.text+0x6): undefined reference to `omp_get_num_threads' C:\Users\Me\AppData\Local\Temp\cccobKR8.ltrans0.ltrans.o:cccobKR8.ltrans0.o:(.text+0xd): undefined reference to `omp_get_thread_num' C:\Users\Me\AppData\Local\Temp\cccobKR8.ltrans0.ltrans.o:cccobKR8.ltrans0.o:(.text.startup+0x26): undefined reference to `GOMP_parallel_start' C:\Users\Me\AppData\Local\Temp\cccobKR8.ltrans0.ltrans.o:cccobKR8.ltrans0.o:(.text.startup+0x37): undefined reference to `GOMP_parallel_end' could not unlink output filecollect2.exe: error: ld returned 1 exit status This all works fine in gcc 4.7.2 with the same build configuration. Using built-in specs. COLLECT_GCC=D:\Programme\msys\gcc\bin\gcc.exe COLLECT_LTO_WRAPPER=d:/programme/msys/gcc/bin/../libexec/gcc/mingw32/4.8.0/lto-wrapper.exe Target: mingw32 Configured with: ../gcc-4.8.0-r196092/configure --enable-languages=c,ada,c++,fortran,objc,obj-c++ --disable-sjlj-exceptions --disable-nls --disable-shared --enable-static --enable-fully-dynamic-string --enable-libgomp --enable-lto --with-dwarf2 --disable-win32-registry --enable-version-specific-runtime-libs --enable-bootstrap --build=mingw32 --enable-abi=32 --enable-checking=release --prefix=/mingw Thread model: win32 gcc version 4.8.0 20130215 (experimental) (GCC)