Re: [Toybox] [PATCH] libcutils isn't in the NDK.

2018-10-17 Thread Rob Landley
On 10/17/2018 04:51 PM, enh wrote:
> i think what you have is broken even for static builds, since you have
> an ODR violation from the missing `static inline` on your no-op
> function:
> 
> ld.lld: error: duplicate symbol: __android_log_write
 defined at portability.h:282 (external/toybox/lib/portability.h:282)

 out/soong/.intermediates/external/toybox/toybox_vendor/android_arm64_armv8-a_cortex-a73_vendor/obj/external/toybox/lib/args.o:(__android_log_write)
 defined at portability.h:282 (external/toybox/lib/portability.h:282)

 out/soong/.intermediates/external/toybox/toybox_vendor/android_arm64_armv8-a_cortex-a73_vendor/obj/external/toybox/toys/android/setprop.o:(.text.__android_log_write+0x0)

Hmmm... it built for me, but yes it seems to screw up dynamic builds with the
ndk. Blah. (I wasn't building that here because I can't run it locally.)

I'd love to be able to use the NDK to build a dynamic mkroot root filesystem,
but I don't think I can beat a native comiler out of this install script (can
I?) and dynamic library installation out of a toolchain is... fraught.

I've tried to make it work before, and I think I left off at
https://github.com/landley/mkroot/blob/master/module/dynamic
(which is just a mess).

It's on my todo heap. :)

The big design change between aboriginal linux and mkroot is outsourcing the
toolchains, both source and native, to an external package. Which means
outsourcing the C library build if your target is going to be dynamically
linked, which means installing those binaries _from_ the toolchain, which is
kinda hard to do in a toolchain-agnostic manner. Which relates to my old "six
paths" rant from the dark ages, which google says is in
https://landley.net/ols/ols2007/cross-compiling.html and I _know_ is buried in
the video of the compiler BOF I hosted the next year...

I was actually interested in building bionic from source and slotting it into an
existing toolchain or root filesystem, but there's no makefile or build shell
script for it, I'd have to get ninja working. And the version of ninja installed
in Ubuntu was too old to build AOSP when I tried, I'd have to build tools to
create an environment to build other tools with...

As I said, todo items.

> why am _i_ seeing this building for the platform? because we screwed
> up and __ANDROID_NDK__ was actually getting defined there. thanks for
> finding that :-)

I break everything.

I added "test NDK dynamic build" to the todo list for the release. Alas, I
wasted the past few days arging with OSI about their misnaming of the toybox
license:

Pass 1:

http://lists.opensource.org/pipermail/license-review_lists.opensource.org/2018-September/003519.html

Unanimous assent for doing what I asked.

Pass 2:

http://lists.opensource.org/pipermail/license-review_lists.opensource.org/2018-October/003581.html

Richard Fontana objects nine times, he's the only one who ever tried to push
back against SPDX back in 2015, every other objection is a "me too" reply to
Richard Fontanta (from non-members of OSI), and of course "I googled and found
stuff I won't link to, then when asked for links I say I haven't work to
recreate the search because about:history does not exist":

http://lists.opensource.org/pipermail/license-review_lists.opensource.org/2018-October/003653.html

That's the most recent message I've replied to on the list. Bit of a bad taste
in my mouth at this point.

It's possible soliciting the attached email _might_ have been overkill, but
license arguments make me tetchy. (Kirk was the longest serving maintainer of
the original BSD back at the Berkeley CSRG. The full open source release
happened on his watch.)

Ahem. So... a bit distracted recently. Sorry about that.

Rob
--- Begin Message ---
> To: mckus...@mckusick.com
> From: Rob Landley 
> Subject: License naming question.
> Date: Tue, 16 Oct 2018 17:57:10 -0500
> 
> Hi,
> 
> We spoke at Ohio Linuxfest back in 2013 (you attended my Rise and
> Fall of Copyleft talk, and then we talked in the hallway afterwards).
> 
> I _think_ I told you about my plans to try to promote public domain
> equivalent licensing, a concept which has a wikipedia page now:
> 
> https://en.wikipedia.org/wiki/Public_domain_equivalent_license
> 
> For toybox what I did was take the OpenBSD suggested template license
> off their website and remove the half-sentence requiring people to
> copy that specific license text into derived works, and the resulting
> license made it past Google's lawyers! My toybox project has been
> providing the command line for android since Marshmallow
> (https://lwn.net/Articles/629362/) and we're making progress on
> getting android to build under android, the Bionic libc maintainer
> recently sent me a roadmap update about that:
> 
> https://github.com/landley/toybox/commit/92b359f00057
> 
> I called the resulting license "Zero Clause BSD" (by analogy with
> "Creative Commons Zero" and the existing 4 clause, 3 clause, and 2
> 

Re: [Toybox] [PATCH] libcutils isn't in the NDK.

2018-10-17 Thread enh
On Wed, Oct 17, 2018 at 2:05 PM Rob Landley  wrote:
>
> On 10/10/2018 11:43 AM, enh wrote:
> >> Then it works with glibc and musl, but _not_ with the android NDKr18:
> >
> > yeah, hard to know what to do with something non-standard like that,
> > but if we're in a world where some have one and others have the other,
> > we usually end up having both.
>
> Indeed.
>
> It would be nice if there was a proper reference spec with test suite. I'm
> trying to establish a "minimal base system", but I can only swap out _some_ of
> the components (currently not including the kernel, and thus the kernel 
> headers
> in the toolchains).
>
> > conveniently musl and glibc make _SC_UIO_MAXIOV the same as the
> > existing _SC_IOV_MAX so i'll do the same and it'll even be backwards
> > compatible for old OS releases.
> >
> > added by https://android-review.googlesource.com/c/platform/bionic/+/783682
> > and will be in r19.
>
> Cool.
>
> I was trying to cut the long-delayed release this past weekend (and now plan 
> to
> do it this _coming_ weekend), and r18's all I've got, so I'll probably just
> #ifdef the symbol musl's missing with a TODO to remove it when r19 comes out.

yeah, r19 should out in be december.

looks like you already did this, minus the NDK comment, in
https://github.com/landley/toybox/commit/ace221343e8c8cacfc853006edfe227a85f555b3
? i was going to send you a patch adding the TODO, but if you're
already on it i'll leave it.

btw, 
https://github.com/landley/toybox/commit/b123b11608260218df29acdff8016908e7d213f2
seems to have misunderstood what i was saying about "stub". what i
meant is that the NDK contains .so files with symbols but no code just
so the static linker can check that your code will link at run-time.
but at run-time you'll get the *real* liblog.so from whatever version
of the OS you're running on. so __android_log_write does work for
dynamic builds. (i'm not sure what the right fix is here though,
because you really want to say `#if __static__`, except that's not a
thing.)

i think what you have is broken even for static builds, since you have
an ODR violation from the missing `static inline` on your no-op
function:

ld.lld: error: duplicate symbol: __android_log_write
>>> defined at portability.h:282 (external/toybox/lib/portability.h:282)
>>>
>>> out/soong/.intermediates/external/toybox/toybox_vendor/android_arm64_armv8-a_cortex-a73_vendor/obj/external/toybox/lib/args.o:(__android_log_write)
>>> defined at portability.h:282 (external/toybox/lib/portability.h:282)
>>>
>>> out/soong/.intermediates/external/toybox/toybox_vendor/android_arm64_armv8-a_cortex-a73_vendor/obj/external/toybox/toys/android/setprop.o:(.text.__android_log_write+0x0)

why am _i_ seeing this building for the platform? because we screwed
up and __ANDROID_NDK__ was actually getting defined there. thanks for
finding that :-)

> Rob
___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net


Re: [Toybox] [PATCH] libcutils isn't in the NDK.

2018-10-17 Thread Rob Landley
On 10/10/2018 11:43 AM, enh wrote:
>> Then it works with glibc and musl, but _not_ with the android NDKr18:
> 
> yeah, hard to know what to do with something non-standard like that,
> but if we're in a world where some have one and others have the other,
> we usually end up having both.

Indeed.

It would be nice if there was a proper reference spec with test suite. I'm
trying to establish a "minimal base system", but I can only swap out _some_ of
the components (currently not including the kernel, and thus the kernel headers
in the toolchains).

> conveniently musl and glibc make _SC_UIO_MAXIOV the same as the
> existing _SC_IOV_MAX so i'll do the same and it'll even be backwards
> compatible for old OS releases.
> 
> added by https://android-review.googlesource.com/c/platform/bionic/+/783682
> and will be in r19.

Cool.

I was trying to cut the long-delayed release this past weekend (and now plan to
do it this _coming_ weekend), and r18's all I've got, so I'll probably just
#ifdef the symbol musl's missing with a TODO to remove it when r19 comes out.

Rob
___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net


Re: [Toybox] [PATCH] libcutils isn't in the NDK.

2018-10-10 Thread enh
On Sun, Oct 7, 2018 at 3:12 PM Rob Landley  wrote:
>
> On 10/07/2018 11:30 AM, enh wrote:
> > Bug: https://github.com/landley/toybox/issues/43
>
> That fixes that one (once I pulled your email out of the spam filter, and yes 
> I
> got unsubscribed from my own list again because gmail false positived on the
> "sorry if this one's a duplicate" email from earlier today and refused 
> delivery.
> It's pretty much a daily occurrence at this point.)
>
> But there's another problem, your redo of getconf works wth glibc and bionic,
> but not with a musl-cross-make toolchain:
>
> toys/posix/getconf.c:140:8: error: 'UIO_MAXIOV' undeclared here (not in a
> function); did you mean '_SC_UIO_MAXIOV'?
>CONF(UIO_MAXIOV), CONF(CHAR_BIT),
> ^
>
> Trying its suggestion and switching to _SC_UIO_MAXIOV, ala:
>
> --- a/toys/posix/getconf.c
> +++ b/toys/posix/getconf.c
> @@ -86,7 +86,7 @@ struct config sysconfs[] = {
>CONF(PAGESIZE), CONF(RAW_SOCKETS), CONF(RE_DUP_MAX), CONF(RTSIG_MAX),
>CONF(SEM_NSEMS_MAX), CONF(SEM_VALUE_MAX), CONF(SIGQUEUE_MAX),
>CONF(STREAM_MAX), CONF(SYMLOOP_MAX), CONF(TIMER_MAX), CONF(TTY_NAME_MAX),
> -  CONF(TZNAME_MAX),
> +  CONF(TZNAME_MAX), CONF(UIO_MAXIOV),
>
>/* Names that just don't match the symbol, do it by hand */
>{"_AVPHYS_PAGES", _SC_AVPHYS_PAGES}, {"_PHYS_PAGES", _SC_PHYS_PAGES},
> @@ -137,7 +137,7 @@ struct config limits[] = {
>CONF(CHAR_MAX), CONF(CHAR_MIN), CONF(INT_MAX), CONF(INT_MIN), 
> CONF(SCHAR_MAX)
>CONF(SCHAR_MIN), CONF(SHRT_MAX), CONF(SHRT_MIN), CONF(SSIZE_MAX),
>CONF(UCHAR_MAX), CONF(UINT_MAX), CONF(ULONG_MAX), CONF(USHRT_MAX),
> -  CONF(UIO_MAXIOV), CONF(CHAR_BIT),
> +  CONF(CHAR_BIT),
>/* Not available in glibc without _GNU_SOURCE. */
>{"LONG_BIT", 8*sizeof(long)},
>{"WORD_BIT", 8*sizeof(int)},
>
> Then it works with glibc and musl, but _not_ with the android NDKr18:

yeah, hard to know what to do with something non-standard like that,
but if we're in a world where some have one and others have the other,
we usually end up having both.

conveniently musl and glibc make _SC_UIO_MAXIOV the same as the
existing _SC_IOV_MAX so i'll do the same and it'll even be backwards
compatible for old OS releases.

added by https://android-review.googlesource.com/c/platform/bionic/+/783682
and will be in r19.

> toys/posix/getconf.c:89:21: error: use of undeclared identifier 
> '_SC_UIO_MAXIOV'
>   CONF(TZNAME_MAX), CONF(UIO_MAXIOV),
>
> I can fix this up with portabiliy.h glue (not sure which direction's right
> though), but it's why I was trying the header generation approach in the first
> place. If anybody ever does try to build this command on macosx or freebsd, 
> it's
> likely to be a nightmare. The sed version had a bug and was hard to read, but
> was at least portable in _theory_...
>
> Rob
___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net


Re: [Toybox] [PATCH] libcutils isn't in the NDK.

2018-10-07 Thread Rob Landley
On 10/07/2018 11:30 AM, enh wrote:
> Bug: https://github.com/landley/toybox/issues/43

This commit broke building on musl, because these:

-static inline int get_sched_policy(int tid, void *policy) {return 0;}
-static inline char *get_sched_policy_name(int policy) {return "unknown";}

Need to be defied anywhere that hasn't got them, and you moved them inside
#ifdef __BIONIC__.

Pushed a fix,

Rob
___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net


Re: [Toybox] [PATCH] libcutils isn't in the NDK.

2018-10-07 Thread Rob Landley
On 10/07/2018 11:30 AM, enh wrote:
> Bug: https://github.com/landley/toybox/issues/43

That fixes that one (once I pulled your email out of the spam filter, and yes I
got unsubscribed from my own list again because gmail false positived on the
"sorry if this one's a duplicate" email from earlier today and refused delivery.
It's pretty much a daily occurrence at this point.)

But there's another problem, your redo of getconf works wth glibc and bionic,
but not with a musl-cross-make toolchain:

toys/posix/getconf.c:140:8: error: 'UIO_MAXIOV' undeclared here (not in a
function); did you mean '_SC_UIO_MAXIOV'?
   CONF(UIO_MAXIOV), CONF(CHAR_BIT),
^

Trying its suggestion and switching to _SC_UIO_MAXIOV, ala:

--- a/toys/posix/getconf.c
+++ b/toys/posix/getconf.c
@@ -86,7 +86,7 @@ struct config sysconfs[] = {
   CONF(PAGESIZE), CONF(RAW_SOCKETS), CONF(RE_DUP_MAX), CONF(RTSIG_MAX),
   CONF(SEM_NSEMS_MAX), CONF(SEM_VALUE_MAX), CONF(SIGQUEUE_MAX),
   CONF(STREAM_MAX), CONF(SYMLOOP_MAX), CONF(TIMER_MAX), CONF(TTY_NAME_MAX),
-  CONF(TZNAME_MAX),
+  CONF(TZNAME_MAX), CONF(UIO_MAXIOV),

   /* Names that just don't match the symbol, do it by hand */
   {"_AVPHYS_PAGES", _SC_AVPHYS_PAGES}, {"_PHYS_PAGES", _SC_PHYS_PAGES},
@@ -137,7 +137,7 @@ struct config limits[] = {
   CONF(CHAR_MAX), CONF(CHAR_MIN), CONF(INT_MAX), CONF(INT_MIN), CONF(SCHAR_MAX)
   CONF(SCHAR_MIN), CONF(SHRT_MAX), CONF(SHRT_MIN), CONF(SSIZE_MAX),
   CONF(UCHAR_MAX), CONF(UINT_MAX), CONF(ULONG_MAX), CONF(USHRT_MAX),
-  CONF(UIO_MAXIOV), CONF(CHAR_BIT),
+  CONF(CHAR_BIT),
   /* Not available in glibc without _GNU_SOURCE. */
   {"LONG_BIT", 8*sizeof(long)},
   {"WORD_BIT", 8*sizeof(int)},

Then it works with glibc and musl, but _not_ with the android NDKr18:

toys/posix/getconf.c:89:21: error: use of undeclared identifier '_SC_UIO_MAXIOV'
  CONF(TZNAME_MAX), CONF(UIO_MAXIOV),

I can fix this up with portabiliy.h glue (not sure which direction's right
though), but it's why I was trying the header generation approach in the first
place. If anybody ever does try to build this command on macosx or freebsd, it's
likely to be a nightmare. The sed version had a bug and was hard to read, but
was at least portable in _theory_...

Rob
___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net