Date: Sat, 25 Nov 2023 21:09:50 -0800 From: Bakul Shah <bakul@iitbombay.org> To: Warner Losh <imp@bsdimp.com> Cc: Joseph Holsten <joseph@josephholsten.com>, "freebsd-arm@freebsd.org" <freebsd-arm@freebsd.org> Subject: Re: sbrk Message-ID: <4BA4DB2E-859A-427E-85AC-80F8F266C7BE@iitbombay.org> In-Reply-To: <CANCZdfposZ2b0tDjwaQjqj1RVYKEK%2Bngr66wtkuRyUUq3r74Pw@mail.gmail.com> References: <2F758BA2-F7F5-4A2C-85CF-6969EE50309C@iitbombay.org> <949f8f16-1219-4f4a-abf6-f9727c95681b@Spark> <CANCZdfqcA-kLd3gLWkcD1%2BPGFg48TPAF=OPk9HzRFyaokZbvAQ@mail.gmail.com> <5668E8DE-B3B3-408D-978E-C2358A614803@iitbombay.org> <CANCZdfposZ2b0tDjwaQjqj1RVYKEK%2Bngr66wtkuRyUUq3r74Pw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_0D4BCB9B-6BF2-43FE-879F-A20F0F8808D6 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 On Nov 25, 2023, at 8:56=E2=80=AFPM, Warner Losh <imp@bsdimp.com> wrote: >=20 > I see that it also uses tcc, which I coincidentally was looking at in = the cdefs modernization efforts I've been doing. You'll need at least = one patch to cdefs to get even the basics to compile. And three tests = fail (one doesn't matter, one is constructors and dtors and a third = fails to detect out of bounds access). I think only the ctor/dtor one is = going to make things hard for you. I've not looked into any of the test = failures, just a short-coming in cdefs.h since tcc doesn't support = .symver yet. using tcc fails with In file included from /tmp/v_1001/ncpu.2284299819361377756.tmp.c:430: /usr/include/stdlib.h:352: error: ARM asm not implemented. tcc also doesn't pass as many tests as clang on amd64 (unfortunately, as = it is compiles so much faster). Its native compiler is nowhere near = ready. It doesn't work well with the ported tcc on freebsd (I forget the = details now). But if you have any bug fixes I am interested! > sbrk can be faked with mmap of a large area up front with MAP_GUARD = that's then grown or shrunk as new sbrk calls happen and remapped with = MAP_FIXED. The only draw-back is you need reserve enough address space = for all the program's memory needs (like GB of space maybe). The = MAP_GUARD mappings are relatively cheap until it's actually used. Heck, = you can even map SIGSEGV to check to see if you've "overflowed" the area = to make it bigger (I hate that I know this trick, thank you Bourne = shell). I worked around with #define USE_MMAP 1. SIGSEGV to grow the stack -- that was a problem on V7 shell on 68000! = Luckily now that is only fit for old farts discussion on TUHS :-) > Looks fun to play with. Maybe I'd help (but I already have too many = fun and even more un-fun projects). It seems to be so far but I haven't written enough code to find its = gotchas.= --Apple-Mail=_0D4BCB9B-6BF2-43FE-879F-A20F0F8808D6 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html><head><meta http-equiv=3D"content-type" content=3D"text/html; = charset=3Dutf-8"></head><body style=3D"overflow-wrap: break-word; = -webkit-nbsp-mode: space; line-break: after-white-space;">On Nov 25, = 2023, at 8:56=E2=80=AFPM, Warner Losh <imp@bsdimp.com> = wrote:<br><div><blockquote type=3D"cite"><br = class=3D"Apple-interchange-newline"><div><div style=3D"caret-color: = rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: = normal; font-variant-caps: normal; font-weight: 400; letter-spacing: = normal; text-align: start; text-indent: 0px; text-transform: none; = white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; = text-decoration: none;">I see that it also uses tcc, which I = coincidentally was looking at in the cdefs modernization efforts I've = been doing. You'll need at least one patch to cdefs to get even the = basics to compile. And three tests fail (one doesn't matter, one is = constructors and dtors and a third fails to detect out of bounds = access). I think only the ctor/dtor one is going to make things hard for = you. I've not looked into any of the test failures, just a short-coming = in cdefs.h since tcc doesn't support .symver = yet.</div></div></blockquote><div><br></div>using tcc fails = with</div><div><br></div><div><div><font face=3D"Menlo">In file included = from = /tmp/v_1001/ncpu.2284299819361377756.tmp.c:430:</font></div><div><font = face=3D"Menlo">/usr/include/stdlib.h:352: error: ARM asm not = implemented.</font></div><div><br></div></div><div>tcc also doesn't pass = as many tests as clang on amd64 (unfortunately, as it is compiles so = much faster). Its native compiler is nowhere near = ready.</div><div><br></div><div>It doesn't work well with the ported tcc = on freebsd (I forget the details now). But if you have any bug fixes I = am interested!</div><div><br><blockquote type=3D"cite"><div><div = style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: = 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; = letter-spacing: normal; text-align: start; text-indent: 0px; = text-transform: none; white-space: normal; word-spacing: 0px; = -webkit-text-stroke-width: 0px; text-decoration: none;">sbrk can be = faked with mmap of a large area up front with MAP_GUARD that's then = grown or shrunk as new sbrk calls happen and remapped with MAP_FIXED. = The only draw-back is you need reserve enough address space for all the = program's memory needs (like GB of space maybe). The MAP_GUARD mappings = are relatively cheap until it's actually used. Heck, you can even map = SIGSEGV to check to see if you've "overflowed" the area to make it = bigger (I hate that I know this trick, thank you Bourne = shell).<br></div></div></blockquote><div><br></div>I worked around with = #define USE_MMAP 1.</div><div><br></div><div>SIGSEGV to grow the stack = -- that was a problem on V7 shell on 68000! Luckily now that is only fit = for old farts discussion on TUHS :-)</div><div><br><blockquote = type=3D"cite"><div><div style=3D"caret-color: rgb(0, 0, 0); font-family: = Helvetica; font-size: 18px; font-style: normal; font-variant-caps: = normal; font-weight: 400; letter-spacing: normal; text-align: start; = text-indent: 0px; text-transform: none; white-space: normal; = word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: = none;">Looks fun to play with. Maybe I'd help (but I already have too = many fun and even more un-fun = projects).</div></div></blockquote><br></div><div>It seems to be so far = but I haven't written enough code to find its = gotchas.</div></body></html>= --Apple-Mail=_0D4BCB9B-6BF2-43FE-879F-A20F0F8808D6--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4BA4DB2E-859A-427E-85AC-80F8F266C7BE>