Right. I think this is the right fix:

diff --git a/Makefile b/Makefile
index 0625524b..dab704af 100644
--- a/Makefile
+++ b/Makefile
@@ -529,6 +529,9 @@ $(out)/preboot.bin: $(out)/preboot.elf
 edata = $(shell readelf --syms $(out)/loader.elf | grep "\.edata" | awk 
'{print "0x" $$2}')
 image_size = $$(( $(edata) - $(kernel_vm_base) ))
 
+builder_edata = $(shell readelf --syms $(out)/zfs_builder.elf | grep 
"\.edata" | awk '{print "0x" $$2}')
+builder_image_size = $$(( $(builder_edata) - $(kernel_vm_base) ))
+
 $(out)/loader.img: $(out)/preboot.bin $(out)/loader-stripped.elf
        $(call quiet, dd if=$(out)/preboot.bin of=$@ > /dev/null 2>&1, DD 
$@ preboot.bin)
        $(call quiet, dd if=$(out)/loader-stripped.elf of=$@ conv=notrunc 
obs=4096 seek=16 > /dev/null 2>&1, DD $@ loader-stripped.elf)
@@ -538,7 +541,7 @@ $(out)/loader.img: $(out)/preboot.bin 
$(out)/loader-stripped.elf
 $(out)/zfs_builder.img: $(out)/preboot.bin $(out)/zfs_builder-stripped.elf
        $(call quiet, dd if=$(out)/preboot.bin of=$@ > /dev/null 2>&1, DD 
$@ preboot.bin)
        $(call quiet, dd if=$(out)/zfs_builder-stripped.elf of=$@ 
conv=notrunc obs=4096 seek=16 > /dev/null 2>&1, DD $@ 
zfs_builder-stripped.elf)
-       $(call quiet, scripts/imgedit.py setsize_aarch64 "-f raw $@" 
$(image_size), IMGEDIT $@)
+       $(call quiet, scripts/imgedit.py setsize_aarch64 "-f raw $@" 
$(builder_image_size), IMGEDIT $@)
        $(call quiet, scripts/imgedit.py setargs "-f raw $@" $(cmdline), 
IMGEDIT $@)
 
 endif # aarch64


Could you please see if this works for you?

./scripts/build image=native-example fs=zfs arch=aarch64 -j$(nproc)
./scripts/run.py --arch=aarch64 (will complain of wrong arch of the 
native-example)

On Sunday, July 24, 2022 at 11:25:03 AM UTC-4 n...@scylladb.com wrote:

> On second thought, why does zfs_builder.img depend on the size of 
> loader.elf and not zfs_builder.elf?
> Are you familiar with the Makefile code ("git blame" suggests you wrote 
> it)? Can you please have a look?
> Maybe this use of "image_size" in that specific code is a mistake?
>
> --
> Nadav Har'El
> n...@scylladb.com
>
>
> On Sun, Jul 24, 2022 at 6:21 PM Nadav Har'El <n...@scylladb.com> wrote:
>
>> I think the missing dependency is here (it's in a aarch64-specific 
>> section):
>>
>> $(out)/zfs_builder.img: $(out)/preboot.bin $(out)/zfs_builder-stripped.elf
>>      $(call quiet, dd if=$(out)/preboot.bin of=$@ > /dev/null 2>&1, DD $@ 
>> preboot.bin)
>>      $(call quiet, dd if=$(out)/zfs_builder-stripped.elf of=$@ 
>> conv=notrunc obs=4096 seek=16 > /dev/null 2>&1, DD $@ 
>> zfs_builder-stripped.elf)
>>      $(call quiet, scripts/imgedit.py setsize_aarch64 "-f raw $@" 
>> $(image_size), IMGEDIT $@)
>>      $(call quiet, scripts/imgedit.py setargs "-f raw $@" $(cmdline), 
>> IMGEDIT $@)
>>
>> Note how it needs image_size, which runs readelf on loader.elf, but 
>> doesn't depend on loader.elf.
>>
>> I'll prepare a patch but am not sure I can reproduce it...
>>
>>
>> --
>> Nadav Har'El
>> n...@scylladb.com
>>
>>
>> On Sun, Jul 24, 2022 at 6:09 PM Nadav Har'El <n...@scylladb.com> wrote:
>>
>>> On Mon, Jul 18, 2022 at 6:42 AM Waldek Kozaczuk <jwkoz...@gmail.com> 
>>> wrote:
>>>
>>>> It is weird. I cannot reproduce it. I assume that the aarch64 build 
>>>> failed. Is it 'scripts/build -j$(nproc) arch=aarch64' in the Jenkins 
>>>> machine?
>>>>
>>>
>>> Sort of, you can see in 
>>> https://jenkins.scylladb.com/blue/rest/organizations/jenkins/pipelines/osv-build/runs/1077/log/?start=0
>>> it is:
>>>       
>>>
>>>     make -j4 ARCH=aarch64
>>>
>>>
>>> The failure is:
>>>
>>>
>>>   LINK zfs_builder.elf
>>>   STRIP zfs_builder.elf -> zfs_builder-stripped.elf 
>>> readelf: build/release.aarch64/loader.elf: Error: Not an ELF file - it has 
>>> the wrong magic bytes at the start
>>>
>>>
>>>> I wonder if we have some missing dependency in the makefile. Possibly 
>>>> this line a symptom of some issue:
>>>>
>>>
>>> Yes, I'm guessing this is the case. I'll take a look.
>>>  
>>>
>>>>
>>>> readelf: build/release.aarch64/loader.elf: Error: Not an ELF file - it 
>>>> has the wrong magic bytes at the start
>>>>
>>>>
>>>>
>>>> On Sun, Jul 17, 2022 at 7:46 PM <jen...@scylladb.com> wrote:
>>>>
>>>>> See <
>>>>> https://jenkins.scylladb.com/job/osv-build/1077/display/redirect?page=changes
>>>>> >
>>>>>
>>>>> Changes:
>>>>>
>>>>> [jwkozaczuk] zfs: use spa_dev_path instead of defaulting to 
>>>>> /dev/vblk0.1
>>>>>
>>>>> [jwkozaczuk] zfs: refactor loader to handle loading libsolaris.so
>>>>>
>>>>> [jwkozaczuk] devfs: print details of mounted partition
>>>>>
>>>>> [jwkozaczuk] vfs: support mounting ZFS from non-root partition
>>>>>
>>>>> [jwkozaczuk] zfs: support building rofs+zfs image and second ZFS disk
>>>>>
>>>>> [jwkozaczuk] tests: add misc-zfs-io to all images
>>>>>
>>>>> [jwkozaczuk] zpool import: do not try devices where ZFS is mounted
>>>>>
>>>>> [jwkozaczuk] tests: fix misc-zfs-arc.cc
>>>>>
>>>>> [jwkozaczuk] zfs: allow mounting and building on host
>>>>>
>>>>> [jwkozaczuk] Fix dependabot alert in jolokia module
>>>>>
>>>>>
>>>>> ------------------------------------------
>>>>> [...truncated 683.59 KB...]
>>>>>   CC musl/src/math/log2l.c
>>>>>   CC musl/src/math/logb.c
>>>>>   CC musl/src/math/logbf.c
>>>>>   CC musl/src/math/logbl.c
>>>>>   CC musl/src/math/logf.c
>>>>>   CC musl/src/math/logl.c
>>>>>   CC musl/src/math/lrint.c
>>>>>   CC musl/src/math/lround.c
>>>>>   CC musl/src/math/lroundf.c
>>>>>   CC musl/src/math/lroundl.c
>>>>>   CC musl/src/math/modf.c
>>>>>   CC musl/src/math/modff.c
>>>>>   CC musl/src/math/modfl.c
>>>>>   CC musl/src/math/nan.c
>>>>>   CC musl/src/math/nanf.c
>>>>>   CC musl/src/math/nanl.c
>>>>>   CC musl/src/math/nearbyint.c
>>>>>   CC musl/src/math/nearbyintf.c
>>>>>   CC musl/src/math/nearbyintl.c
>>>>>   CC musl/src/math/nextafter.c
>>>>>   CC musl/src/math/nextafterf.c
>>>>>   CC musl/src/math/nextafterl.c
>>>>>   CC musl/src/math/nexttoward.c
>>>>>   CC musl/src/math/nexttowardf.c
>>>>>   CC musl/src/math/nexttowardl.c
>>>>>   CC musl/src/math/pow.c
>>>>>   CC musl/src/math/powf.c
>>>>>   CC musl/src/math/powf_data.c
>>>>>   CC musl/src/math/powl.c
>>>>>   CC musl/src/math/remainder.c
>>>>>   CC musl/src/math/remainderf.c
>>>>>   CC musl/src/math/remainderl.c
>>>>>   CC musl/src/math/remquo.c
>>>>>   CC musl/src/math/remquof.c
>>>>>   CC musl/src/math/remquol.c
>>>>>   CC musl/src/math/rint.c
>>>>>   CC musl/src/math/rintf.c
>>>>>   CC musl/src/math/rintl.c
>>>>>   CC musl/src/math/round.c
>>>>>   CC musl/src/math/roundf.c
>>>>>   CC musl/src/math/roundl.c
>>>>>   CC musl/src/math/scalb.c
>>>>>   CC musl/src/math/scalbf.c
>>>>>   CC musl/src/math/scalbln.c
>>>>>   CC musl/src/math/scalblnf.c
>>>>>   CC musl/src/math/scalblnl.c
>>>>>   CC musl/src/math/scalbn.c
>>>>>   CC musl/src/math/scalbnf.c
>>>>>   CC musl/src/math/scalbnl.c
>>>>>   CC musl/src/math/signgam.c
>>>>>   CC musl/src/math/significand.c
>>>>>   CC musl/src/math/significandf.c
>>>>>   CC musl/src/math/sin.c
>>>>>   CC musl/src/math/sincos.c
>>>>>   CC musl/src/math/sincosf.c
>>>>>   CC musl/src/math/sinf.c
>>>>>   CC musl/src/math/sinh.c
>>>>>   CC musl/src/math/sinhf.c
>>>>>   CC musl/src/math/sinhl.c
>>>>>   CC musl/src/math/sinl.c
>>>>>   CC musl/src/math/sqrt.c
>>>>>   CC musl/src/math/sqrtf.c
>>>>>   CC musl/src/math/sqrtl.c
>>>>>   CC musl/src/math/tan.c
>>>>>   CC musl/src/math/tanf.c
>>>>>   CC musl/src/math/tanh.c
>>>>>   CC musl/src/math/tanhf.c
>>>>>   CC musl/src/math/tanhl.c
>>>>>   CC musl/src/math/tanl.c
>>>>>   CC musl/src/math/tgamma.c
>>>>>   CC musl/src/math/tgammaf.c
>>>>>   CC musl/src/math/tgammal.c
>>>>>   CC musl/src/math/trunc.c
>>>>>   CC musl/src/math/truncf.c
>>>>>   CC musl/src/math/truncl.c
>>>>>   CC musl/src/misc/a64l.c
>>>>>   CC musl/src/misc/get_current_dir_name.c
>>>>>   CC musl/src/misc/getsubopt.c
>>>>>   CC musl/src/multibyte/btowc.c
>>>>>   CC musl/src/multibyte/internal.c
>>>>>   CC musl/src/multibyte/mblen.c
>>>>>   CC musl/src/multibyte/mbrtowc.c
>>>>>   CC musl/src/multibyte/mbsrtowcs.c
>>>>>   CC musl/src/multibyte/mbstowcs.c
>>>>>   CC musl/src/multibyte/mbtowc.c
>>>>>   CC musl/src/multibyte/wcrtomb.c
>>>>>   CC musl/src/multibyte/wcstombs.c
>>>>>   CC musl/src/multibyte/wctob.c
>>>>>   CC musl/src/multibyte/wctomb.c
>>>>>   CC musl/src/network/gethostbyaddr.c
>>>>>   CC musl/src/network/resolvconf.c
>>>>>   CC musl/src/network/res_msend.c
>>>>>   CC musl/src/network/lookup_ipliteral.c
>>>>>   CC musl/src/network/lookup_name.c
>>>>>   CC musl/src/network/lookup_serv.c
>>>>>   CC musl/src/network/inet_aton.c
>>>>>   CC musl/src/network/gai_strerror.c
>>>>>   CC musl/src/network/getservbyname_r.c
>>>>>   CC musl/src/network/getservbyport_r.c
>>>>>   CC musl/src/network/getifaddrs.c
>>>>>   CC musl/src/network/if_nameindex.c
>>>>>   CC musl/src/network/if_freenameindex.c
>>>>>   CC musl/src/prng/rand.c
>>>>>   CC musl/src/prng/rand_r.c
>>>>>   CC musl/src/prng/drand48.c
>>>>>   CC musl/src/prng/lcong48.c
>>>>>   CC musl/src/prng/lrand48.c
>>>>>   CC musl/src/prng/mrand48.c
>>>>>   CC musl/src/prng/seed48.c
>>>>>   CC musl/src/prng/srand48.c
>>>>>   CC musl/src/search/tsearch.c
>>>>>   CC musl/src/stdio/__fclose_ca.c
>>>>>   CC musl/src/stdio/__overflow.c
>>>>>   CC musl/src/stdio/__stdio_close.c
>>>>>   CC musl/src/stdio/__stdio_exit.c
>>>>>   CC musl/src/stdio/__stdio_seek.c
>>>>>   CC musl/src/stdio/__stdio_write.c
>>>>>   CC musl/src/stdio/__string_read.c
>>>>>   CC musl/src/stdio/__toread.c
>>>>>   CC musl/src/stdio/__towrite.c
>>>>>   CC musl/src/stdio/__uflow.c
>>>>>   CC musl/src/stdio/ofl_add.c
>>>>>   CC musl/src/stdio/clearerr.c
>>>>>   CC musl/src/stdio/ext.c
>>>>>   CC musl/src/stdio/ext2.c
>>>>>   CC musl/src/stdio/fclose.c
>>>>>   CC musl/src/stdio/feof.c
>>>>>   CC musl/src/stdio/ferror.c
>>>>>   CC musl/src/stdio/fflush.c
>>>>>   CC musl/src/stdio/fgetln.c
>>>>>   CC musl/src/stdio/fgetpos.c
>>>>>   CC musl/src/stdio/fgets.c
>>>>>   CC musl/src/stdio/fgetwc.c
>>>>>   CC musl/src/stdio/fgetws.c
>>>>>   CC musl/src/stdio/fileno.c
>>>>>   CC musl/src/stdio/fopen.c
>>>>>   CC musl/src/stdio/fputs.c
>>>>>   CC musl/src/stdio/fputwc.c
>>>>>   CC musl/src/stdio/fputws.c
>>>>>   CC musl/src/stdio/fread.c
>>>>>   CC musl/src/stdio/freopen.c
>>>>>   CC musl/src/stdio/fseek.c
>>>>>   CC musl/src/stdio/fsetpos.c
>>>>>   CC musl/src/stdio/ftell.c
>>>>>   CC musl/src/stdio/fwide.c
>>>>>   CC musl/src/stdio/fwrite.c
>>>>>   CC musl/src/stdio/getc_unlocked.c
>>>>>   CC musl/src/stdio/getchar_unlocked.c
>>>>>   CC musl/src/stdio/getdelim.c
>>>>>   CC musl/src/stdio/gets.c
>>>>>   CC musl/src/stdio/getwc.c
>>>>>   CC musl/src/stdio/getwchar.c
>>>>>   CC musl/src/stdio/perror.c
>>>>>   CC musl/src/stdio/putc_unlocked.c
>>>>>   CC musl/src/stdio/putchar_unlocked.c
>>>>>   CC musl/src/stdio/puts.c
>>>>>   CC musl/src/stdio/putwc.c
>>>>>   CC musl/src/stdio/putwchar.c
>>>>>   CC musl/src/stdio/rewind.c
>>>>>   CC musl/src/stdio/tempnam.c
>>>>>   CC musl/src/stdio/tmpfile.c
>>>>>   CC musl/src/stdio/tmpnam.c
>>>>>   CC musl/src/stdio/ungetc.c
>>>>>   CC musl/src/stdio/ungetwc.c
>>>>>   CC musl/src/stdio/vasprintf.c
>>>>>   CC musl/src/stdio/vfscanf.c
>>>>>   CC musl/src/stdio/vfwprintf.c
>>>>>   CC musl/src/stdio/vfwscanf.c
>>>>>   CC musl/src/stdlib/abs.c
>>>>>   CC musl/src/stdlib/atof.c
>>>>>   CC musl/src/stdlib/atoi.c
>>>>>   CC musl/src/stdlib/atol.c
>>>>>   CC musl/src/stdlib/atoll.c
>>>>>   CC musl/src/stdlib/bsearch.c
>>>>>   CC musl/src/stdlib/div.c
>>>>>   CC musl/src/stdlib/ecvt.c
>>>>>   CC musl/src/stdlib/fcvt.c
>>>>>   CC musl/src/stdlib/gcvt.c
>>>>>   CC musl/src/stdlib/labs.c
>>>>>   CC musl/src/stdlib/ldiv.c
>>>>>   CC musl/src/stdlib/llabs.c
>>>>>   CC musl/src/stdlib/lldiv.c
>>>>>   CC musl/src/stdlib/qsort.c
>>>>>   CC musl/src/string/strdup.c
>>>>>   CC musl/src/string/strndup.c
>>>>>   CC musl/src/string/strsignal.c
>>>>>   CC musl/src/string/wcsdup.c
>>>>>   CC musl/src/temp/mkdtemp.c
>>>>>   CC musl/src/temp/mkstemp.c
>>>>>   CC musl/src/temp/mktemp.c
>>>>>   CC musl/src/temp/mkostemp.c
>>>>>   CC musl/src/temp/mkostemps.c
>>>>>   CC musl/src/time/asctime_r.c
>>>>>   CC musl/src/time/getdate.c
>>>>>   CC musl/src/time/strftime.c
>>>>>   CC musl/src/time/strptime.c
>>>>>   CC musl/src/time/wcsftime.c
>>>>>   CC musl/src/regex/fnmatch.c
>>>>>   CC musl/src/regex/glob.c
>>>>>   CC musl/src/regex/regcomp.c
>>>>>   CC musl/src/regex/regexec.c
>>>>>   CC musl/src/regex/regerror.c
>>>>>   CC musl/src/regex/tre-mem.c
>>>>>   CC musl/src/fenv/fegetexceptflag.c
>>>>>   CC musl/src/fenv/feholdexcept.c
>>>>>   CC musl/src/fenv/fesetexceptflag.c
>>>>>   CC musl/src/fenv/fesetround.c
>>>>>   CC musl/src/crypt/crypt_sha256.c
>>>>>   CC musl/src/crypt/crypt_sha512.c
>>>>>   CC musl/src/crypt/encrypt.c
>>>>>   CC musl/src/locale/iconv.c
>>>>>   CC musl/src/locale/iconv_close.c
>>>>>   CXX fs/nfs/nfs_null_vfsops.cc
>>>>>   CXX tools/mkfs/mkfs.cc
>>>>>   LINK build/release.aarch64/libuutil.so
>>>>>   LINK libsolaris.so
>>>>>   LINK build/release.aarch64/tools/uush/uush.so
>>>>>   LINK build/release.aarch64/tools/uush/ls.so
>>>>>   LINK build/release.aarch64/tools/uush/mkdir.so
>>>>>   LINK build/release.aarch64/tools/mount/mount-fs.so
>>>>>   LINK build/release.aarch64/tools/mount/umount.so
>>>>>   LINK build/release.aarch64/tests/tst-hello.so
>>>>>   LINK libzfs.so
>>>>>   LINK cpiod.so
>>>>>   LINK zpool.so
>>>>>   LINK zfs.so
>>>>>   LINK mkfs.so
>>>>>   MKBOOTFS build/release.aarch64/bootfs.bin
>>>>>   MKBOOTFS build/release.aarch64/zfs_builder_bootfs.bin
>>>>>   AS bootfs.S
>>>>>   AS zfs_builder_bootfs.S
>>>>>   LINK loader.elf
>>>>>   LINK zfs_builder.elf
>>>>>   STRIP zfs_builder.elf -> zfs_builder-stripped.elf 
>>>>> readelf: build/release.aarch64/loader.elf: Error: Not an ELF file - it 
>>>>> has the wrong magic bytes at the start
>>>>>   DD build/release.aarch64/zfs_builder.img preboot.bin
>>>>>   DD build/release.aarch64/zfs_builder.img zfs_builder-stripped.elf
>>>>>   IMGEDIT build/release.aarch64/zfs_builder.img
>>>>>   LIBOSV.SO
>>>>> Traceback (most recent call last):
>>>>>   File "<
>>>>> https://jenkins.scylladb.com/job/osv-build/ws/scripts/imgedit.py";,> 
>>>>> line 167, in <module>
>>>>>     f.write(struct.pack('<Q', size))
>>>>> struct.error: argument out of range
>>>>> make: *** [Makefile:541: build/release.aarch64/zfs_builder.img] Error 1
>>>>> make: *** Deleting file 'build/release.aarch64/zfs_builder.img'
>>>>> make: *** Waiting for unfinished jobs....
>>>>> Build step 'Execute shell' marked build as failure
>>>>> ERROR: Not all environment variables could be successfully injected. 
>>>>> Check for similarly-named environment variables.
>>>>> Not sending mail to user jwkoz...@gmail.com with no permission to 
>>>>> view osv-build #1077
>>>>>
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google 
>>>>> Groups "OSv Development" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>> an email to osv-dev+u...@googlegroups.com.
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/osv-dev/1079622082.252.1658101609192%4060.58.228.35.bc.googleusercontent.com
>>>>> .
>>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "OSv Development" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to osv-dev+u...@googlegroups.com.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/osv-dev/CAL9cFfNbD-E_bg58W_okobKTHU0bnWzenaY-nAF%2BUDa3DyS0pg%40mail.gmail.com
>>>>  
>>>> <https://groups.google.com/d/msgid/osv-dev/CAL9cFfNbD-E_bg58W_okobKTHU0bnWzenaY-nAF%2BUDa3DyS0pg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/bfb3aefd-01dc-45bc-8010-50dcade41764n%40googlegroups.com.

Reply via email to