oss-fuzz icon indicating copy to clipboard operation
oss-fuzz copied to clipboard

helper: build_image on ARM does not add the --platform=linux/amd64 flag by default

Open marcellomaugeri opened this issue 8 months ago • 2 comments

This will cause the build_image on ARM architecture (like Mac) to default to an arm64 image. Will be fixed and tested next week.

Quick (temporary) fix: Add this snippet on line 670 in helper.py

if architecture == 'x86_64':
    build_args += ['--platform', 'linux/amd64']

marcellomaugeri avatar Apr 10 '25 14:04 marcellomaugeri

On my Mac, I had this error:

 - InvalidBaseImagePlatform: Base image gcr.io/oss-fuzz-base/base-builder-python was pulled with platform "linux/amd64", expected "linux/arm64" for current build (line 17)

This patch seems to fix it:

diff --git a/infra/helper.py b/infra/helper.py
index 1f00332..d8136a9 100755
--- a/infra/helper.py
+++ b/infra/helper.py
@@ -695,6 +695,8 @@ def build_image_impl(project, cache=True, pull=False, architecture='x86_64'):
         'plain',
         '--load',
     ]
+  if architecture == 'x86_64':
+    build_args += ['--platform', 'linux/amd64']
   if not cache:
     build_args.append('--no-cache')

Can we get this fixed so that maintainers don't have to reverse-engineer the fuzzer to fix problems?

nedbat avatar Jun 12 '25 10:06 nedbat

@nedbat I'll create a pull request right now. However, further testing is needed on other architectures. It should work everywhere, but I haven't tried it on more advanced architectures.

marcellomaugeri avatar Jun 12 '25 10:06 marcellomaugeri