# HG changeset patch # User Michael Goffioul # Date 1372699871 14400 # Node ID 31edb6eea0eb38496d7953af3d5eb407cb27d5f1 # Parent 50135b4423ec7d264ba678320ede53389a10defa [MSVC] fix cc-msvc when INCLUDE/LIB variables are empty, improve compatibility with MinGW. diff -r 50135b4423ec -r 31edb6eea0eb src/build-msvctools/cc-msvc.cc --- a/src/build-msvctools/cc-msvc.cc Mon Jul 01 13:31:08 2013 -0400 +++ b/src/build-msvctools/cc-msvc.cc Mon Jul 01 13:31:11 2013 -0400 @@ -324,8 +324,11 @@ else root.resize (root.size () - 4); - string include_var = getenv ("INCLUDE"); - string lib_var = getenv ("LIB"); + char * include_var_s = getenv ("INCLUDE"); + char * lib_var_s = getenv ("LIB"); + + string include_var = (include_var_s ? include_var_s : ""); + string lib_var = (lib_var_s ? lib_var_s : ""); if (include_var.empty ()) include_var = "INCLUDE=" + root + "\\include"; @@ -469,6 +472,11 @@ // do not pass those to the linker clopt += (" " + arg); } + else if (arg == "-O3") + { + // MSVC does not support -O3, convert to -O2 instead + clopt += " -O2"; + } else if (starts_with(arg, "-I")) { string path = arg.substr(2); @@ -557,7 +565,8 @@ } else if (arg == "-m386" || arg == "-m486" || arg == "-mpentium" || arg == "-mpentiumpro" || arg == "-pedantic" || starts_with(arg, "-W") || - arg == "-fPIC" || arg == "-nostdlib" || arg == "--export-all-symbols") + arg == "-fPIC" || arg == "-nostdlib" || arg == "--export-all-symbols" || + starts_with(arg, "-march=") || arg == "-fomit-frame-pointer") { // ignore } @@ -716,7 +725,11 @@ linkopt += " -IMPLIB:" + implib; } else if (arg == "--enable-auto-import" - || arg == "--enable-auto-image-base") + || arg == "--enable-auto-image-base" + || arg == "--whole-archive" + || arg == "--no-whole-archive" + || arg == "-Bsymbolic" + || arg == "-s") { // Ignore these. } @@ -726,6 +739,28 @@ if (it == Xlinkopt.end ()) break; } + else if (arg == "--image-base" + || starts_with(arg, "--image-base=")) + { + string base_addr; + + if (arg == "--image-base") + { + ++it; + if (it != Xlinkopt.end ()) + base_addr = *it; + else + { + cerr << "WARNING: missing base address, ignored" << endl; + continue; + } + } + else + base_addr = arg.substr (13); + + cllinkopt += " -BASE:" + base_addr; + linkopt += " -BASE:" + base_addr; + } else { cllinkopt += " " + arg;