Closed Bug 1544797 Opened 5 years ago Closed 5 years ago

mach clang-format attempt to reformat unified-build files instead of source files.

Categories

(Developer Infrastructure :: Lint and Formatting, defect, P2)

defect

Tracking

(firefox68 fixed)

RESOLVED FIXED
mozilla68
Tracking Status
firefox68 --- fixed

People

(Reporter: nbp, Assigned: Sylvestre)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

Running mach clang-format --path js/src/jit --output stdout attempts to reformat the Unified_cpp_js_src_jit*.cpp files instead of the source files.

Adding a print(args + l) at the following line[1] prints:

Processing 16 file(s)...
[u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/.mozbuild/clang-tools/clang-tidy/bin/clang-format', u'-i', u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/tmp/Unified_cpp_js_src_jit0.cpp']
[u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/.mozbuild/clang-tools/clang-tidy/bin/clang-format', u'-i', u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/tmp/Unified_cpp_js_src_jit1.cpp']
[u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/.mozbuild/clang-tools/clang-tidy/bin/clang-format', u'-i', u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/tmp/Unified_cpp_js_src_jit10.cpp']
[u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/.mozbuild/clang-tools/clang-tidy/bin/clang-format', u'-i', u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/tmp/Unified_cpp_js_src_jit11.cpp']
[u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/.mozbuild/clang-tools/clang-tidy/bin/clang-format', u'-i', u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/tmp/Unified_cpp_js_src_jit12.cpp']
[u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/.mozbuild/clang-tools/clang-tidy/bin/clang-format', u'-i', u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/tmp/Unified_cpp_js_src_jit13.cpp']
[u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/.mozbuild/clang-tools/clang-tidy/bin/clang-format', u'-i', u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/tmp/Unified_cpp_js_src_jit14.cpp']
[u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/.mozbuild/clang-tools/clang-tidy/bin/clang-format', u'-i', u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/tmp/Unified_cpp_js_src_jit15.cpp']
[u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/.mozbuild/clang-tools/clang-tidy/bin/clang-format', u'-i', u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/tmp/Unified_cpp_js_src_jit2.cpp']
[u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/.mozbuild/clang-tools/clang-tidy/bin/clang-format', u'-i', u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/tmp/Unified_cpp_js_src_jit3.cpp']
[u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/.mozbuild/clang-tools/clang-tidy/bin/clang-format', u'-i', u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/tmp/Unified_cpp_js_src_jit4.cpp']
[u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/.mozbuild/clang-tools/clang-tidy/bin/clang-format', u'-i', u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/tmp/Unified_cpp_js_src_jit5.cpp']
[u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/.mozbuild/clang-tools/clang-tidy/bin/clang-format', u'-i', u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/tmp/Unified_cpp_js_src_jit6.cpp']
[u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/.mozbuild/clang-tools/clang-tidy/bin/clang-format', u'-i', u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/tmp/Unified_cpp_js_src_jit7.cpp']
[u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/.mozbuild/clang-tools/clang-tidy/bin/clang-format', u'-i', u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/tmp/Unified_cpp_js_src_jit8.cpp']
[u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/.mozbuild/clang-tools/clang-tidy/bin/clang-format', u'-i', u'/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/tmp/Unified_cpp_js_src_jit9.cpp']

The previous mach command is executed in the source directory /home/nicolas/mozilla/wksp-7/ and with following environment variables:

export builddir=/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg/
export MOZBUILD_STATE_PATH=$builddir/.mozbuild;
export MOZCONFIG=$builddir/.mozconfig;

And the custom $MOZCONFIG file contains the following lines:

# Do not source automation scripts, but read them to reverse engineer options
# that we want.
# . "$topsrcdir/build/mozconfig.common"

# Content of $MOZCONFIG_TEMPLATE provided by the shellHook of the derivation.
mk_add_options AUTOCONF=/nix/store/f6q9rqcx51ksq4s8pp02cr4iihn6xa28-autoconf-2.13/bin/autoconf
ac_add_options --with-libclang-path=/nix/store/8rlcpaxcp85mzga4pjr07parkxy3yl5k-clang-5.0.2-lib/lib
ac_add_options --with-clang-path=/nix/store/54n9w9xqx0qln2sj80ll78hb39l4hj43-clang-wrapper-5.0.2/bin/clang
export BINDGEN_CFLAGS="-cxx-isystem /nix/store/czxcii58v6d3yhrq9r667zw91192rcgk-gcc-7.3.0/include/c++/7.3.0 -isystem /nix/store/czxcii58v6d3yhrq9r667zw91192rcgk-gcc-7.3.0/include/c++/7.3.0/x86_64-unknown-linux-gnu"
export CC="/nix/store/54n9w9xqx0qln2sj80ll78hb39l4hj43-clang-wrapper-5.0.2/bin/cc"
export CXX="/nix/store/54n9w9xqx0qln2sj80ll78hb39l4hj43-clang-wrapper-5.0.2/bin/c++"

# Content produced by make.sh generate_conf_args function
mk_add_options MOZ_OBJDIR=/home/nicolas/mozilla/_build/firefox/bugzil.la/arm64/wip/arm64/clang/dbg
mk_add_options AUTOCLOBBER=1
ac_add_options --prefix=/home/nicolas/mozilla/_inst/firefox/bugzil.la/arm64/wip/arm64/clang/dbg
ac_add_options --enable-application=browser
ac_add_options --disable-install-strip
ac_add_options --enable-js-shell
ac_add_options --disable-jemalloc
ac_add_options --enable-valgrind
ac_add_options --disable-pulseaudio
ac_add_options --enable-jitspew
ac_add_options --enable-ctypes
ac_add_options --enable-oom-breakpoint
ac_add_options --enable-debug=-ggdb3
ac_add_options --disable-optimize
ac_add_options --enable-warnings-as-errors
ac_add_options --disable-tests
ac_add_options --enable-simulator=arm64

[1] https://searchfox.org/mozilla-central/rev/1b2636e8517aa48422ed516affe4d28cb7fa220a/python/mozbuild/mozbuild/mach_commands.py#3321

I cannot reproduce with the following:

export builddir=/tmp/nbp/
export MOZBUILD_STATE_PATH=$builddir/.mozbuild;
export MOZCONFIG=$builddir/.mozconfig;
echo "ac_add_options --enable-application=browser" > $MOZCONFIG
./mach clang-format --path js/src/jit --output stdout

It returns:

Processing 348 file(s)...

(In reply to Nicolas B. Pierron [:nbp] from comment #0)

The previous mach command is executed in the source directory /home/nicolas/mozilla/wksp-7/ and with following environment variables:

Ok, this statement is incorrect. The $srcdir/mach command is executed from the $builddir path. With:

  cd $builddir
  $srcdir/mach clang-format --path js/src/jit --output stdout

So, I have a found a work-around which is to execute the mach command within the source directory.

OK, I can reproduce:

export builddir=/tmp/nbp/
export MOZBUILD_STATE_PATH=$builddir/.mozbuild;
export MOZCONFIG=$builddir/.mozconfig;
echo "mk_add_options MOZ_OBJDIR=/tmp/nbp" >> $MOZCONFIG
cd $builddir
$OLDPWD/mach clang-format --path js/src/jit --output stdout
Priority: -- → P2
Regressed by: clang-format
Keywords: regression
Assignee: nobody → sledru

If the user runs mach clang-format from the builddir, it was finding and using
unified files.

Pushed by sledru@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ebcc8dd9c2bc
clang-format: Use the topsrcdir to generate the paths instead of the pwd r=andi
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
Has Regression Range: --- → yes
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.