From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pb-smtp21.pobox.com ([173.228.157.53]) by ewsd; Wed Jul 29 02:09:14 EDT 2020 Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id DF29AEDF12; Wed, 29 Jul 2020 02:08:55 -0400 (EDT) (envelope-from unobe@cpan.org) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=date :in-reply-to:references:mime-version:content-type :content-transfer-encoding:subject:to:from:message-id; s=sasl; bh=+vrpeqT1fJjiEcOCW/sIcgz5Fn0=; b=K7XuOCR6DITrFuwKx4odbRu4lqnS 7bKHfK6InBPi4zvPI+Ev+G+SxPljDkm7ISA1G1DppOMJfXuLlvIGryldBb8OuCkZ U9lL8ELZ5YpfusAxF3aFjL31SFDABRMR8ow3wO62VcPti0LGcKUhDMFBM+o4ZUhw kw6EGeukkdkIwW8= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id CB1FAEDF11; Wed, 29 Jul 2020 02:08:55 -0400 (EDT) (envelope-from unobe@cpan.org) Received: from [10.0.1.31] (unknown [137.25.138.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id 0D4D4EDF10; Wed, 29 Jul 2020 02:08:53 -0400 (EDT) (envelope-from unobe@cpan.org) Date: Wed, 29 Jul 2020 06:08:53 +0000 In-Reply-To: <1B1B16C8-C577-4155-A61D-292785CED256@cpan.org> References: <592FB65470BC7FE96B27C51B46F47948@gmail.com> <6B88F8FA-F050-4BAA-A15E-18D67664C74F@cpan.org> <1B1B16C8-C577-4155-A61D-292785CED256@cpan.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: arm64 fails to link when float converted to int (Was Re: [9front] netsurf native frontend (text_insert: illegal combination FCVTZSDW FCON NONE REG)) To: 9front@9front.org,telephil9@gmail.com From: Romano Message-ID: X-Pobox-Relay-ID: FA5DB5A0-D161-11EA-A959-843F439F7C89-09620299!pb-smtp21.pobox.com List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: secure information just-in-time just-in-time-aware optimizer TLDR; netsurf/frontends/plan9/drawui/entry=2Ec:162 multiplies d->entry by 1= =2E5=2E Changing the factor to 2 (an int) resolves=2E Here's a test =2Ec fi= le that reproduces the problem: cpu% cat arm64-int-test=2Ec #include #include void main() { int size =3D 1; size*=3D1=2E5; exits(0); } cpu% 7c arm64-int-test=2Ec cpu% 7l arm64-int-test=2E7 main: illegal combination FCVTZSDW FCON NONE REG (833) FCVTZSDW $1=2E500000e+00,R2 main: illegal combination FCVTZSDW FCON NONE REG (833) FCVTZSDW $1=2E500000e+00,R2 cpu% Narrative: So I tried poking around a bit more: googling initially didn't appear all = that helpful=2E It appears the logic is the same as Go's compiler, which re= fers to 7l from Plan9 (copyrights dating back to the '90s)=2E I ran acid to= show the stack trace and the registers=2E I don't know how to determine wh= ich archived library code this machine code is being generated for, or if t= hat's even the place to look for this type of error=2E=20 cpu% acid /bin/7l /bin/7l:arm64 plan 9 executable /sys/lib/acid/port /sys/lib/acid/arm64 acid: progargs =3D "-o 7=2Enetsurf utils/bloom=2E7 utils/corestrings=2E7 u= tils/file=2E7 utils/filename=2E7 utils/filepath=2E7 utils/hashmap=2E7 utils= /hashtable=2E7 utils/http/cache-control=2E7 utils/http/challenge=2E7 utils/= http/content-disposition=2E7 utils/http/content-type=2E7 utils/http/generic= s=2E7 utils/http/parameter=2E7 utils/http/primitives=2E7 utils/http/strict-= transport-security=2E7 utils/http/www-authenticate=2E7 utils/idna=2E7 utils= /libdom=2E7 utils/log=2E7 utils/messages=2E7 utils/nsoption=2E7 utils/nsurl= /nsurl=2E7 utils/nsurl/parse=2E7 utils/punycode=2E7 utils/ssl_certs=2E7 uti= ls/talloc=2E7 utils/time=2E7 utils/url=2E7 utils/useragent=2E7 utils/utf8= =2E7 utils/utils=2E7 content/content=2E7 content/content_factory=2E7 conten= t/dirlist=2E7 content/fetch=2E7 content/fetchers/about=2E7 content/fetchers= /data=2E7 content/fetchers/file=2E7 content/fetchers/resource=2E7 content/f= s_backing_store=2E7 content/handlers/css/css=2E7 content/handlers/css/dump= =2E7 content/handlers/css/hints=2E7 content/handlers/css/internal=2E7 conte= nt/handlers/css/select=2E7 content/handlers/css/utils=2E7 content/handlers/= html/box=2E7 content/handlers/html/box_construct=2E7 content/handlers/html/= box_normalise=2E7 content/handlers/html/box_textarea=2E7 content/handlers/h= tml/font=2E7 content/handlers/html/form=2E7 content/handlers/html/html=2E7 = content/handlers/html/html_css=2E7 content/handlers/html/html_css_fetcher= =2E7 content/handlers/html/html_forms=2E7 content/handlers/html/html_object= =2E7 content/handlers/html/html_redraw=2E7 content/handlers/html/html_redra= w_border=2E7 content/handlers/html/html_script=2E7 content/handlers/html/im= agemap=2E7 content/handlers/html/interaction=2E7 content/handlers/html/layo= ut=2E7 content/handlers/html/search=2E7 content/handlers/html/table=2E7 con= tent/handlers/image/bmp=2E7 content/handlers/image/gif=2E7 content/handlers= /image/ico=2E7 content/handlers/image/image=2E7 content/handlers/image/imag= e_cache=2E7 content/handlers/javascript/content=2E7 content/handlers/javasc= ript/duktape/dukky=2E7 content/handlers/javascript/duktape/duktape=2E7 cont= ent/handlers/javascript/fetcher=2E7 content/handlers/text/textplain=2E7 con= tent/hlcache=2E7 content/llcache=2E7 content/mimesniff=2E7 content/no_backi= ng_store=2E7 content/urldb=2E7 content/webfs=2E7 desktop/browser=2E7 deskto= p/browser_history=2E7 desktop/browser_window=2E7 desktop/cookie_manager=2E7= desktop/cw_helper=2E7 desktop/download=2E7 desktop/font_haru=2E7 desktop/f= rames=2E7 desktop/global_history=2E7 desktop/gui_factory=2E7 desktop/hotlis= t=2E7 desktop/knockout=2E7 desktop/local_history=2E7 desktop/mouse=2E7 desk= top/netsurf=2E7 desktop/page-info=2E7 desktop/plot_style=2E7 desktop/print= =2E7 desktop/save_pdf=2E7 desktop/save_text=2E7 desktop/scrollbar=2E7 deskt= op/search=2E7 desktop/searchweb=2E7 desktop/selection=2E7 desktop/sslcert_v= iewer=2E7 desktop/system_colour=2E7 desktop/textarea=2E7 desktop/textinput= =2E7 desktop/treeview=2E7 desktop/version=2E7 frontends/plan9/plotter=2E7 f= rontends/plan9/schedule=2E7 frontends/plan9/window=2E7 frontends/plan9/fetc= h=2E7 frontends/plan9/bitmap=2E7 frontends/plan9/layout=2E7 frontends/plan9= /clipboard=2E7 frontends/plan9/utils=2E7 frontends/plan9/gui=2E7 frontends/= plan9/drawui/data=2E7 frontends/plan9/drawui/window=2E7 frontends/plan9/dra= wui/button=2E7 frontends/plan9/drawui/entry=2E7 frontends/plan9/drawui/tool= bar=2E7 frontends/plan9/drawui/scrollbar=2E7 =2E=2E/posix/src/iconv=2E7 =2E= =2E/posix/src/preadwrite=2E7 =2E=2E/posix/src/math9=2E7 content/handlers/ja= vascript/duktape/libduktape=2E7=2Ea =2E=2E/libnspsl/src/libnspsl=2E7=2Ea = =2E=2E/libdom/src/libdom=2E7=2Ea =2E=2E/libcss/src/libcss=2E7=2Ea =2E=2E/li= bhubbub/src/libhubbub=2E7=2Ea =2E=2E/libparserutils/src/libparserutils=2E7= =2Ea =2E=2E/libwapcaplet/src/libwapcaplet=2E7=2Ea =2E=2E/libnsutils/src/lib= nsutils=2E7=2Ea =2E=2E/libnslog/src/libnslog=2E7=2Ea =2E=2E/libnsbmp/src/li= bnsbmp=2E7=2Ea =2E=2E/libnsgif/src/libnsgif=2E7=2Ea =2E=2E/libutf8proc/src/= libutf8proc=2E7=2Ea /arm64/lib/ape/libap=2Ea" acid: new() 144283: ??? _main MOV R30,-160(SP)! 144283: ??? main+0x4 MOVWU R0,104(SP) Notes pending: sys: trap: BRK instruction acid: filepc("/sys/src/cmd/7l/span=2Ec:749") :4: (error) no function pcwhere acid: filepc("/sys/src/cmd/7l/span=2Ec:749") acid: ma =3D filepc("/sys/src/cmd/7l/span=2Ec:751") acid: print(ma) 123496 acid: setbp(123496) :10: (error) no function setbp acid: bpset(123496) acid: cont() text_insert: illegal combination FCVTZSDW FCON NONE REG 144283: ??? oplook+0x248 BL prasm(SB) Notes pending: sys: trap: BRK instruction acid: lstk() oplook(p=3D0x52ea258)+0x248 /sys/src/cmd/7l/span=2Ec:751 a1=3D0x1935000000012 a3=3D0x1b0c969000000001 e=3D0x32b70 o=3D0x0 span()+0x7c /sys/src/cmd/7l/span=2Ec:37 bflag=3D0x400000000 otxt=3D0x163bec00163bd0 c=3D0x163bec p=3D0x52ea258 m=3D0x7000000004 main(argc=3D0x8e,argv=3D0x1fffef180)+0x494 /sys/src/cmd/7l/obj=2Ec:240 _argc=3D0x6f _args=3D0x1fffef193 _main+0x28 /sys/src/libc/arm64/main9=2Es:17 acid: regs() R0 0x00000000052ea258 R1 0x00000001fffee810 R2 0x0000000000028bf4 R3 0x0000000020000000 R4 0x0000000000000001 R5 0x000000000002339b R6 0x0000000000000120 R7 0x0000000000000000 R8 0x000000004a200000 R9 0x0000000000000000 R10 0x00000001fffeea30 R11 0x0000000000000000 R12 0x0000000000000038 R13 0x0000000000000038 R14 0x0000000000000038 R15 0x0000000000000038 R16 0x97a3d7a220310c00 R17 0xffffffffc00f9f0c R18 0x0875b486156a038a R19 0xabbd7f2d00000600 R20 0xbdfb65a508018891 R21 0xfb8eef8303a1c056 R22 0x7701204088940008 R23 0x30bd38232a00814d R24 0x0ba2cb7a34057080 R25 0xf6faa6d3e3bed2fb R26 0xffffffffc08e20a8 R27 0xffffffffc007e000 R28 0x0000000000030000 R29 0xffffffffc0088958 R30 0x000000000001e264 acid: step() (1705) FCVTZSDW $1=2E500000e+00,R5 text_insert: illegal combination FCVTZSDW FCON NONE REG (1705) FCVTZSDW $1=2E500000e+00,R5 :21: (error) msg: pid=3D144283 startstop: process exited acid: From=20a couple of the Go sources, it's clear that FCVTZSDW is converting 64= float to 32int[1][2],so for me it's understandable that 1=2E5 can't be conv= erted to an integer=2E The connection of 1=2E5e0 to 1=2E5 didn't dawn on me= immediately, however=2E I ended up watching a youtube on ARM development, = then reading ARM developer docs and a blog post about ARM development[3]: t= hey all didn't seem to help me understand how to figure out the location of= the problem=2E So after a bit of contemplation, I figured searching for 1= =2E5 in the netsurf source might yield something=2E Since 7=2Ensfb builds f= ine, I wasn't quite sure it would help much, but what had I to lose, except= more time? cpu% walk =2E | grep '\=2Ec$' | xargs grep '[^0-9]1\=2E5' =2E/content/handlers/css/select=2Ec: FLTTOFIX(1=2E5000), /* x-large */ =2E/content/handlers/html/layout=2Ec: size =3D FLTTOFIX(1=2E5); =2E/content/handlers/javascript/duktape/duktape=2Ec: * (e=2Eg=2E '1=2E5= e+2')=2E This clause catches NULs=2E =2E/content/handlers/javascript/duktape/duktape=2Ec: * -1=2E5 -> floor(-= 1=2E0) -> -1 (towards +Inf) =2E/content/handlers/javascript/duktape/duktape=2Ec: * +1=2E5 -> floor(+= 2=2E0) -> 2 (towards +Inf) =2E/content/handlers/javascript/duktape/duktape=2Ec: * Lua 5=2E1=2E5, and= different hash initializer=2E =2E/content/handlers/javascript/duktape/duktape=2Ec: /* Number/string -> c= oerce string to number (e=2Eg=2E "'1=2E5' =3D=3D 1=2E5" -> true)=2E */ =2E/content/handlers/javascript/duktape/duktape=2Ec: * 10=2E2=2E1=2E1= =2E5 DeleteBinding (N) [declarative environment record] =2E/content/handlers/javascript/duktape/duktape=2Ec: * the double is out-= of-range=2E C99 Section 6=2E3=2E1=2E5: =2E/frontends/riscos/window=2Ec: 1=2E5, 2=2E0, 3=2E0, 4=2E0, 6=2E0, 8= =2E0, 12=2E0, 16=2E0}; =2E/frontends/plan9/drawui/entry=2Ec: entry->size *=3D 1=2E5; Huh, 1=2E5 in plan9 drawui=2E Change that to 2, and the linking was succes= sful! I'm happy that netsurf now builds on arm64, but this raises a questi= on of why this doesn't cause a problem for i386 (the other arch I built net= surf on back in May)=2E I reviewed the dentry struct in entry=2Eh in the sa= me directory and see that entry is of type int, so maybe on other architect= ures it's just rounded? For instance, on p=2E 42 in The C Programming Langu= age, Section 2=2E7 contains this section: "Expressions that might lose info= rmation , like assigning a longer integer type to a shorter, or a floating-= point type to an integer, may draw a warning, but they are not illegal=2E" = The arm64 compiler could emit the warning but still apply the operation (ma= ybe it would be something like converting the int to a float, then multiply= ing, then rounding to get an int again)=2E At any rate, the test script ab= ove can be used as a test for anyone looking to reproduce the problem, and = if desired, provide a solution=2E [1] https://www=2Egolang=2Eir/src/cmd/compile/internal/ssa/opGen=2Ego [2] https://www=2Egolang=2Eir/src/cmd/compile/internal/ssa/rewriteARM64=2E= go [3] https://modexp=2Ewordpress=2Ecom/2018/10/30/arm64-assembly/ On Tue, Jul 28, 2020, at 12:11 AM, Romano wrote: > Philippe, >=20 > I attempted to build on a rpi4 using the arm64 kernel ( I ran a=20 > sysupdate on Saturday)=2E The framebuffer executable builds fine, but at= =20 > the very last step of building the native front-end I'm getting an=20 > error: >=20 > pcc -o 7=2Enetsurf utils/bloom=2E7 utils/corestrings=2E7 utils/file=2E7= =20 > utils/filename=2E7 utils/filepath=2E7 utils/hashmap=2E7 utils/hashtable= =2E7=20 > utils/http/cache-control=2E7 utils/http/challenge=2E7=20 > utils/http/content-disposition=2E7 utils/http/content-type=2E7=20 > utils/http/generics=2E7 utils/http/parameter=2E7 utils/http/primitives= =2E7=20 > utils/http/strict-transport-security=2E7 utils/http/www-authenticate=2E7= =20 > utils/idna=2E7 utils/libdom=2E7 utils/log=2E7 utils/messages=2E7=20 > utils/nsoption=2E7 utils/nsurl/nsurl=2E7 utils/nsurl/parse=2E7=20 > utils/punycode=2E7 utils/ssl_certs=2E7 utils/talloc=2E7 utils/time=2E7= =20 > utils/url=2E7 utils/useragent=2E7 utils/utf8=2E7 utils/utils=2E7=20 > content/content=2E7 content/content_factory=2E7 content/dirlist=2E7=20 > content/fetch=2E7 content/fetchers/about=2E7 content/fetchers/data=2E7= =20 > content/fetchers/file=2E7 content/fetchers/resource=2E7=20 > content/fs_backing_store=2E7 content/handlers/css/css=2E7=20 > content/handlers/css/dump=2E7 content/handlers/css/hints=2E7=20 > content/handlers/css/internal=2E7 content/handlers/css/select=2E7=20 > content/handlers/css/utils=2E7 content/handlers/html/box=2E7=20 > content/handlers/html/box_construct=2E7=20 > content/handlers/html/box_normalise=2E7=20 > content/handlers/html/box_textarea=2E7 content/handlers/html/font=2E7=20 > content/handlers/html/form=2E7 content/handlers/html/html=2E7=20 > content/handlers/html/html_css=2E7=20 > content/handlers/html/html_css_fetcher=2E7=20 > content/handlers/html/html_forms=2E7 content/handlers/html/html_object= =2E7=20 > content/handlers/html/html_redraw=2E7=20 > content/handlers/html/html_redraw_border=2E7=20 > content/handlers/html/html_script=2E7 content/handlers/html/imagemap=2E7= =20 > content/handlers/html/interaction=2E7 content/handlers/html/layout=2E7= =20 > content/handlers/html/search=2E7 content/handlers/html/table=2E7=20 > content/handlers/image/bmp=2E7 content/handlers/image/gif=2E7=20 > content/handlers/image/ico=2E7 content/handlers/image/image=2E7=20 > content/handlers/image/image_cache=2E7=20 > content/handlers/javascript/content=2E7=20 > content/handlers/javascript/duktape/dukky=2E7=20 > content/handlers/javascript/duktape/duktape=2E7=20 > content/handlers/javascript/fetcher=2E7 content/handlers/text/textplain= =2E7=20 > content/hlcache=2E7 content/llcache=2E7 content/mimesniff=2E7=20 > content/no_backing_store=2E7 content/urldb=2E7 content/webfs=2E7=20 > desktop/browser=2E7 desktop/browser_history=2E7 desktop/browser_window= =2E7=20 > desktop/cookie_manager=2E7 desktop/cw_helper=2E7 desktop/download=2E7=20 > desktop/font_haru=2E7 desktop/frames=2E7 desktop/global_history=2E7=20 > desktop/gui_factory=2E7 desktop/hotlist=2E7 desktop/knockout=2E7=20 > desktop/local_history=2E7 desktop/mouse=2E7 desktop/netsurf=2E7=20 > desktop/page-info=2E7 desktop/plot_style=2E7 desktop/print=2E7=20 > desktop/save_pdf=2E7 desktop/save_text=2E7 desktop/scrollbar=2E7=20 > desktop/search=2E7 desktop/searchweb=2E7 desktop/selection=2E7=20 > desktop/sslcert_viewer=2E7 desktop/system_colour=2E7 desktop/textarea=2E= 7=20 > desktop/textinput=2E7 desktop/treeview=2E7 desktop/version=2E7=20 > frontends/plan9/plotter=2E7 frontends/plan9/schedule=2E7=20 > frontends/plan9/window=2E7 frontends/plan9/fetch=2E7=20 > frontends/plan9/bitmap=2E7 frontends/plan9/layout=2E7=20 > frontends/plan9/clipboard=2E7 frontends/plan9/utils=2E7=20 > frontends/plan9/gui=2E7 frontends/plan9/drawui/data=2E7=20 > frontends/plan9/drawui/window=2E7 frontends/plan9/drawui/button=2E7=20 > frontends/plan9/drawui/entry=2E7 frontends/plan9/drawui/toolbar=2E7=20 > frontends/plan9/drawui/scrollbar=2E7 =2E=2E/posix/src/iconv=2E7=20 > =2E=2E/posix/src/preadwrite=2E7 =2E=2E/posix/src/math9=2E7=20 > content/handlers/javascript/duktape/libduktape=2E7=2Ea=20 > =2E=2E/libnspsl/src/libnspsl=2E7=2Ea =2E=2E/libdom/src/libdom=2E7=2Ea=20 > =2E=2E/libcss/src/libcss=2E7=2Ea =2E=2E/libhubbub/src/libhubbub=2E7=2Ea= =20 > =2E=2E/libparserutils/src/libparserutils=2E7=2Ea=20 > =2E=2E/libwapcaplet/src/libwapcaplet=2E7=2Ea =2E=2E/libnsutils/src/libns= utils=2E7=2Ea=20 > =2E=2E/libnslog/src/libnslog=2E7=2Ea =2E=2E/libnsbmp/src/libnsbmp=2E7=2E= a=20 > =2E=2E/libnsgif/src/libnsgif=2E7=2Ea =2E=2E/libutf8proc/src/libutf8proc= =2E7=2Ea > text_insert: illegal combination FCVTZSDW FCON NONE REG > (1705) FCVTZSDW $1=2E500000e+00,R5 > text_insert: illegal combination FCVTZSDW FCON NONE REG > (1705) FCVTZSDW $1=2E500000e+00,R5 > pcc: 7l: 7l 101895: error > mk: pcc -o 7=2Enetsurf =2E=2E=2E : exit status=3Drc 101892: pcc 101894:= 7l: 7l=20 > 101895: error >=20 > Any ideas? Is this is a problem with the 7l linker specifically not=20 > knowing how to translate an instruction to arm64 assembly? Do you need= =20 > more information? >=20 > On Thu, May 21, 2020, at 10:59 AM, Romano wrote: > > Very cool, Philippe! > >=20 > > I'm testing a build now on 386=2E > >=20 > > Maybe it was mentioned previously and I didn't see it, but it looks=20 > > like nsport is what someone needs to clone first:=20 > > http://github=2Ecom/netsurf-plan9/nsport =2E Then cd into that dir and= run=20 > > 'fetch clone git', 'fetch clone ssh' or 'fetch clone http' (the=20 > > instructions in README=2Eplan9 say a simple 'fetch clone' without args= =20 > > would work, but it didn't work for me)=2E > >=20 > > Note also that git9 changed the flag for creating a new branch: you=20 > > might have to update the fetch script to use -n instead of -c=2E > >=20 > > I'll let you know how the build goes, and if I run in to any other got= chas=2E > >=20 > >=20 > >=20 > > On May 21, 2020 3:54:03 PM UTC, telephil9@gmail=2Ecom wrote: > > >Hi, > > > > > >I've just committed the initial release for the netsurf native > > >frontend=2E > > >Feature-wise it is almost on par with the framebuffer frontend except > > >for images that are not handled yet=2E > > >I tried to make it look and behave like a native application but woul= d > > >like to have some feedback on this=2E > > > > > >All code is in the main repository: http://github=2Ecom/netsurf-plan9 > > > > > >In order not to mess with the current framebuffer frontend, I created= a > > >separate mkfile found in netsurf/mkfile=2Enative=2E > > >To build this new frontend, just run mk as usual and then run mk -f > > >mkfile=2Enative in the netsurf directory=2E > > > > > >Regards, > > >Philippe > >