Closed Bug 1475566 Opened 3 years ago Closed 2 years ago

Use -fms-extensions in mingw clang builds


(Firefox Build System :: General: Unsupported Platforms, defect, P5)

60 Branch


(firefox-esr6064+ fixed, firefox63 fixed)

Tracking Status
firefox-esr60 64+ fixed
firefox63 --- fixed


(Reporter: jacek, Assigned: tjr)


(Blocks 1 open bug)



(3 files)

clang (which in fact shares code with clang-cl) supports many msvc-specific extensions and quirks. Some of those would be very nice to have. The closer we're to msvc in terms of comatibility, the less mingw-specific problems we will hit.

I tried it briefly and it looked promising. It may need some fixes on mingw-w64 side. The main issue I've seen was that #pragma comment attempted to work, but for example for:
#pragma comment(lib, "ole32.lib")
linker tried to link ole32.lib, but mingw toolchain provides libole32.a instead. We could disable those pragmas in Mozilla, but having them working properly and unmodified would be better.
Blocks: 1481633
Attached patch HacksSplinter Review
I could get Firefox to build with CXXFLAGS="-fms-extensions" in mozconfig (this should be done in configure script, but it's just for testing).

The hack mostly works around problem I described in comment 1. It removes #pragma comment(lib, ...). We import those libs in files anyway, so they are not really needed. I still think that this should be properly supported by llvm and/or mingw-w64. I briefly looked at what would be needed for llvm to fix it, and it doesn't look hard. I'm attaching it here to allow experimenting with it meantime.
In the MinGW browser build job, we're going to use -fms-extensions,
which will tell clang to start processing these comments. Clang
cannot process them correctly (it's an upstream bug) but it doesn't
need to, because we include the libs we need in files.

So we exclude them for MinGW builds. mingw-clang gets them wrong and
mingw-gcc (which doesn't even work anymore on -central) ignored them.

In the future, with a llvm fix, we could clean up the
files and re-enable these comments.
Comment on attachment 9001683 [details]
Bug 1475566 Disable #pragma comments for MinGW Builds r=glandium

Mike Hommey [:glandium] has approved the revision.
Attachment #9001683 - Flags: review+
Pushed by
Disable #pragma comments for MinGW Builds r=glandium
Keywords: checkin-needed
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
[ESR Uplift Approval Request]

If this is not a sec:{high,crit} bug, please state case for ESR consideration: Needed to fix the mingw-clang build for esr60

User impact if declined: Tor will have to carry this patch themselves, and we won't be able to run mingw-clang in automation.

Fix Landed on Version: 63.0a1 / 20180829100131

Risk to taking this patch: Low

Why is the change risky/not risky? (and alternatives if risky): Only affects mingw builds

String or UUID changes made by this patch:
Attachment #9024555 - Flags: approval-mozilla-esr60?
Comment on attachment 9024555 [details] [diff] [review]
Bug 1475566 - Disable #pragma comments for MinGW Builds (rebased) r=glandium

Support for downstream builds, let's uplift for ESR 60.4.0.
Attachment #9024555 - Flags: approval-mozilla-esr60? → approval-mozilla-esr60+
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.