Workaround: MIDL1004-C Preprocessor Error

mozilla firefox

If you’ve been trying to build firefox using the mozilla build tool, you may have encountered the following  mach build errors :

command line error MIDL1004 : cannot execute C preprocessor cl.exe
mozmake.EXE[3]: * [c:/mozilla-source/mozilla-central/config/recurse.mk:33: export] Error 2 0:58.03
mozmake.EXE[2]: * [c:/mozilla-source/mozilla-central/config/rules.mk:453: default] Error 2 0:58.03
mozmake.EXE[1]: * [c:/mozilla-source/mozilla-central/client.mk:424: realbuild] Error 2

Bug 1397263 seems to cause an issue with the latest version of mozilla build and its support with MIDL imports.

A workaround to successfully build:

**Assuming you’ve already installed MozillaBuild 3.0 Latest

  1. In C:/mozilla-build rename the existing start-shell.bat to start-shell.bat.bak
  2. Download and save the following files from the MozillaBuild 2.2.0 release to your existing   C:/mozilla-build directory

https://hg.mozilla.org/mozilla-build/file/d2218e17d480/start-shell.bat

https://hg.mozilla.org/mozilla-build/file/d2218e17d480/start-shell-msvc2015.bat

  1. Start the mozilla-build bash window by opening start-shell-msvc2015.bat
  2. Execute the following commands:

PATH=$PATH:~/.cargo/bin

cd C:/mozilla-source/mozilla-central

mach clobber

mach bootstrap

//select option 2

//select yes to take you through the setup

mach build  //This will take a while

mach run

Your browser should successfully compile and launch.

If you’re experiencing any other build issues or have an alternative solution, feel free to comment below.

2 Responses
  1. Whitney

    I’m having 2 issues.

    1. If I try to do mach bootstrap I get an error: CalledProcessError: Command ‘[u’c:/Users/wclarke\\.cargo\\bin\\rustup’, ‘target’
    , ‘add’, ‘i686-pc-windows-msvc’]’ returned non-zero exit status 1

    – AND –

    2. When I attempt to build I get an error: 4:39.92 ERROR: Could not find LLVM/Clang installation for compiling stylo build
    -time
    4:39.92 bindgen. Please specify the ‘LLVM_CONFIG’ environment variable
    4:39.92 (recommended), pass the ‘–with-libclang-path’ and ‘–with-clang-path’
    4:39.92 options to configure, or put ‘llvm-config’ in your PATH. Altering your

    4:39.92 PATH may expose ‘clang’ as well, potentially altering your compiler,
    4:39.92 which may not be what you intended.
    4:40.13 *** Fix above errors and then restart with\
    4:40.13 “c:/mozilla-build/mozmake/mozmake.EXE -f client.mk build

    4:40.14 mozmake.EXE: *** [client.mk:383: configure] Error 1
    2
    I never got these until trying to compile 56 and upgrade mozilla-build.

    Any suggestions?

    1. Hi Whitney,

      I also experienced the LLVM/CLANG issue. It’s possible that your either missing Rust and LLVM/CLANG or it’s not in the your “PATH” environment variable.
      I would suggest downloading each dependency separately.
      Click the links below and select the installer for your system. Follow the setup for each package. After installation has completed, restart your computer and try to rebuild.

      Rust: https://www.rust-lang.org/en-US/install.html
      LLVM/CLANG: http://releases.llvm.org/download.html

Leave a Reply

Categories

Follow me on Twitter