Workaround: MIDL1004-C Preprocessor Error

Mozilla Logo

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.

9 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

  2. Whitney

    Unfortunately, I have already tried that. I feel at a loss with Firefox 56. I can’t get mozilla-build to run mach bootstrap – I keep getting a: CalledProcessError: Command ‘[u’c:/Users/wclarke\\.cargo\\bin\\rustup’, ‘target’, ‘add’, ‘i686-pc-windows-msvc’]’ returned non-zero exit status 1
    error every time. I thought that might be the issue. Tried on a clean Windows 10 machine since we are upgrading at work and I had to reinstall everything going through the build prerequisties for windows again and same thing. I tried mach doctor and to a mach eror trying to load _psutils_windows python. It worked in 54 and now 56 they change everything again with sucky documentation. If I wasn’t doing this for the office I would have quit by now.

    Any other suggestions???

    Thanks for your quick reply!!!

        1. It looks like your missing the rust toolchain.
          Have you tried reinstalling rust on its on from
          https://www.rustup.rs/

          You should get a similar result when running the rustup show command:

          Default host: x86_64-pc-windows-msvc
          
          installed targets for active toolchain
          --------------------------------------
          
          i686-pc-windows-msvc
          x86_64-pc-windows-msvc
          
          active toolchain
          ----------------
          
          stable-x86_64-pc-windows-msvc (default)
          (timeout reading rustc version)
          
  3. Whitney

    This is interesting. When I install it from the exe it forces x86_64 and refuses to allow install of i686, which booststrap is looking for. I got it installed correctly after forcing it via command line with the correct rustup show, however, when I ran mach bootstrap I got the same error as the first one AND when I ran rustup show again I got the url missing error again. This makes NO sense at all. It’s a clean Windows 10 system, followed all of Mozilla’s steps, it’s crazy… never had an issue with mozilla-build before now.

    1. I’m pretty sure this should do the trick.

      Install rust with x86_64
      In mozilla-source/mozilla-central/.mozconfig (create the .mozconfig file if it doesn’t exist) add the following lines:

      ac_add_options –target=x86_64-pc-mingw32
      ac_add_options –host=x86_64-pc-mingw32

      1. Whitney

        mach build has an issue with it: it is throwing odd characters in front of the -target line and is saying it needs –, which I also did. Sigh… I’m concerned that I can’t run bootstrap with this being a brand new install on a windows 10 machine. It is also odd that I am getting the exact same errors on the clean install as I did on the windows 7 machine I was trying to update and the new install on a windows 7 laptop. Don’t know if that information helps at all…

Add a comment...

Categories

Follow me on Twitter

%d bloggers like this: