ninja-build / ninja

a small build system with a focus on speed
https://ninja-build.org/
Apache License 2.0
11.22k stars 1.6k forks source link

ninja_test fails with qemu-user-static for arm32v7 and arm64 linux. #2091

Open devizer opened 2 years ago

devizer commented 2 years ago

ninja_test fails with qemu-user-static for arm32v7 and arm64 linux (qemu user static is used indirectly using multi-arch arm docker containers on a x86_64 host)

Environment. ninja source: 1.10.2 qemu user static from Ubuntu 20.04 LTS host or Ubuntu 22.04 host cmake 3.22.2 (latest) as: any from debian 7 to debian 11 gcc and g++: any from 4.6 to 11.2

way to build:

# current folder is /root/build/ninja-src/ninja-build-ninja-e72d1d5
mkdir build-cmake; cd build-cmake
time (cmake ..; make -j)
./ninja_test

On ARM device (without qemu user static) the tests successfully passes But on qemu user static tests fails:

... (skipped)
[318/343] StringPieceUtilTest.JoinStringPiece
[319/343] StringPieceUtilTest.ToLowerASCII
[320/343] StringPieceUtilTest.EqualsCaseInsensitiveASCII
[321/343] SubprocessTest.BadCommandStderr
[322/343] SubprocessTest.NoSuchCommand
[323/343] SubprocessTest.InterruptChild
[324/343] SubprocessTest.InterruptParent
*** Failure in /root/build/ninja-src/ninja-build-ninja-e72d1d5/src/subprocess_test.cc:98
"We should have been interrupted"
Bash exited with code '130'.

The Error above is the same for both armv7 and arm64

Does it mean that ninja is also not supported on qemu-user-static similar to fallen tests?

Regarding the meaning of the fallen test ninja should work on qemu user static only in case of a successful build?

detailed logs for arm64: https://devizer.visualstudio.com/azure-pipelines-agent-in-docker/_build/results?buildId=4153&view=logs&j=7c60bfc2-167c-5b1b-5be9-865e702bf402&t=32b10ecb-ab6a-5034-d91c-f8092388e1c4&l=17489 for arm32v7: https://devizer.visualstudio.com/azure-pipelines-agent-in-docker/_build/results?buildId=4153&view=logs&j=5f481cd5-447a-56e3-74e4-cde703207979&t=fa56abaa-8f76-5e48-9282-d57a6ccb8500&l=17731

UPDATE: If I zeroing src/subprocess_test.cc then ./ninja_test succesully passes on qemu-user-static.

digit-google commented 2 years ago

There is nothing in that test (subprocess_test.cc::SubprocessTest::InterruptParent that seems wrong, i.e.:

  Subprocess* subproc = subprocs_.Add("kill -INT $PPID ; sleep 1");
  ASSERT_NE((Subprocess *) 0, subproc);

  while (!subproc->Done()) {
    bool interrupted = subprocs_.DoWork();
    if (interrupted)
      return;
  }

  ASSERT_FALSE("We should have been interrupted");

I suspect this is a qemu-user bug where PPID doesn't have the right value for some reason. Also see https://mail.gnu.org/archive/html/qemu-devel/2021-06/msg05537.html which seems relatively recent, a ppid-related fix in qemu-user from June 2021. I suggest asking in the qemu-devel@ mailing list first for clues about what's happening.

jonesmz commented 2 years ago

You might consider adding qemu based emulation on the CI system as a way to catch this kind of incompatibility.

The current .github/workflows/ folder is where the CI steps live.

If you want a version that's slightly less crazy, you can take a look at this PR: https://github.com/ninja-build/ninja/pull/2109

rickou commented 1 year ago

hello !

i'm facing the same issue trying to build ninja in an ARM docker container (running on a windows host) the process is not interrupted for the 3 tests INT, TERM and HUP..

someone have any news ??

i need ninja for installing scipy in the docker image.. but at this time I don't find a working workaround