mordak / playbook-dev-tools

gcc for the Blackberry Playbook, and maybe some other stuff..
54 stars 31 forks source link

`qcc` in `clitools` on device? #14

Open KireinaHoro opened 7 years ago

KireinaHoro commented 7 years ago

I'm trying to bootstrap Gentoo Prefix after having gotten the toolchain onto my Q10 (and bootstrapping bash and curl). Things like m4 and wget went smoothly, but when I was building python-2.7.3 I encountered problems. make complains about not being able to find qcc:

rm -f libpython2.7.a
ar rc libpython2.7.a Modules/getbuildinfo.o
ar rc libpython2.7.a Parser/acceler.o Parser/grammar1.o Parser/listnode.o Parser/node.o Parser/parser.o Parser/parsetok.o Parser/bitset.o Parser/metagrammar.o Parser/firstsets.o Parser/grammar.o Parser/pgen.o Parser/myreadline.o Parser/tokenizer.o
ar rc libpython2.7.a Objects/abstract.o Objects/boolobject.o Objects/bufferobject.o Objects/bytes_methods.o Objects/bytearrayobject.o Objects/capsule.o Objects/cellobject.o Objects/classobject.o Objects/cobject.o Objects/codeobject.o Objects/complexobject.o Objects/descrobject.o Objects/enumobject.o Objects/exceptions.o Objects/genobject.o Objects/fileobject.o Objects/floatobject.o Objects/frameobject.o Objects/funcobject.o Objects/intobject.o Objects/iterobject.o Objects/listobject.o Objects/longobject.o Objects/dictobject.o Objects/memoryobject.o Objects/methodobject.o Objects/moduleobject.o Objects/object.o Objects/obmalloc.o Objects/rangeobject.o Objects/setobject.o Objects/sliceobject.o Objects/stringobject.o Objects/structseq.o Objects/tupleobject.o Objects/typeobject.o Objects/weakrefobject.o Objects/unicodeobject.o Objects/unicodectype.o
ar rc libpython2.7.a Python/_warnings.o Python/Python-ast.o Python/asdl.o Python/ast.o Python/bltinmodule.o Python/ceval.o Python/compile.o Python/codecs.o Python/errors.o Python/frozen.o Python/frozenmain.o Python/future.o Python/getargs.o Python/getcompiler.o Python/getcopyright.o Python/getplatform.o Python/getversion.o Python/graminit.o Python/import.o Python/importdl.o Python/marshal.o Python/modsupport.o Python/mystrtoul.o Python/mysnprintf.o Python/peephole.o Python/pyarena.o Python/pyctype.o Python/pyfpe.o Python/pymath.o Python/pystate.o Python/pythonrun.o Python/random.o Python/structmember.o Python/symtable.o Python/sysmodule.o Python/traceback.o Python/getopt.o Python/pystrcmp.o Python/pystrtod.o Python/dtoa.o Python/formatter_unicode.o Python/formatter_string.o Python/dynload_shlib.o   Python/thread.o
ar rc libpython2.7.a Modules/config.o Modules/getpath.o Modules/main.o Modules/gcmodule.o 
ar rc libpython2.7.a Modules/threadmodule.o  Modules/signalmodule.o  Modules/posixmodule.o  Modules/errnomodule.o  Modules/pwdmodule.o  Modules/_sre.o  Modules/_codecsmodule.o  Modules/_weakref.o  Modules/zipimport.o  Modules/symtablemodule.o  Modules/xxsubtype.o
ranlib libpython2.7.a
qcc -L/accounts/1000/shared/documents/gentoo/tmp/usr/lib -L/accounts/1000/shared/documents/gentoo/tmp/usr/lib64 -Wl,-E -N 2048K -o python2.7 \
        Modules/python.o \
        libpython2.7.a -lsocket    -lm  
make: qcc: Command not found
make: *** [python2.7] Error 127

while qcc is listed as LINKCC=qcc in /accounts/1000/documents/gentoo/tmp/var/tmp/python-2.7.3/Python-2.7.3/Makefile (and perhaps in the subdirectories' Makefiles as well).

After some digging around, I found that qcc is short for QNX CC and exists in the SDK. I have no idea how python's configure knows about this and how to get it to the device (we certainly don't have QNX CC's source code!)

KireinaHoro commented 7 years ago

Probably because of the configure script behaving oddly on this platform. When I was bootstrapping bash-4.1, configure created odd Makefiles, feeding an option -3s to gcc in LOCAL_CFLAGS (which none of the gccs I have access to recognizes) and trying to link something like libunix by -lunix (in LOCAL_LIBS).

I don't know why, though, as I got around these by simply removing them :/

KireinaHoro commented 7 years ago

Things that looks like to be relevant:

https://supportforums.blackberry.com/t5/Native-Development/HOWTO-Cross-Compile-Python-with-Native-Libraries-Part-1/td-p/3085463

This is about cross-compiling, though.

KireinaHoro commented 7 years ago

Using the SDK to build on PC will also make strange things. (like bash-4.1 produces the following:)

gcc -3s -g -DCROSS_COMPILING -o mkbuiltins mkbuiltins.o -lsocket
gcc: error: unrecognized command line option ‘-3s’; did you mean ‘-Os’?
Makefile:201: recipe for target 'mkbuiltins' failed
make[1]: *** [mkbuiltins] Error 1
make[1]: Leaving directory '/home/jsteward/projects/blackberry/playbook-dev-tools/work/bash-4.1/builtins'
Makefile:679: recipe for target 'builtins/builtext.h' failed
make: *** [builtins/builtext.h] Error 1

You can test it here.

KireinaHoro commented 7 years ago

Bad news:

We no longer ship a self-hosted version of QNX SDP (that is, you can no longer use the QNX Neutrino RTOS itself to develop programs).

Source: http://www.qnx.com/developers/articles/rel_5849_7.html#Deprecated

mordak commented 7 years ago

Welcome to porting and cross compiling. :-)

qcc is indeed the QNX CC, but if you run it with the -v flag from the SDK it emits some stuff about looking for gcc, so it seems like gcc might do most of the work? In any event, python is probably looking for it because python has been ported to QNX, so the build system is expecting qcc to be installed as the system compiler.

You can often get hints about how to configure / patch something so it will compile natively from the QNX pkgsrc repo:

http://community.qnx.com/sf/projects/pkgsrc/

Browse under the 'Source Code' tab and navigate to the most recent branch to see the ports tree.

Often you can use the same configuration params or pull patches from here to make the same package compile on BB10, but not always (sometimes BB10 is missing libs or something that are part of the usual QNX install).

Cross compiling sometimes works, and sometimes not. I recall trying to get bash to cross compile some time ago and ended up giving up in favour of mksh. It might compile on the device, but I haven't tried.

In any event, keep at it! Most things will work with a little tweaking. I find the biggest obstacles are missing syslog.h, and anything that uses SA_RESTART with sigaction, but you can usually work around these.

KireinaHoro commented 7 years ago

The above link won't open (The page isn’t redirecting properly)

KireinaHoro commented 7 years ago

BTW, how do you generate patches for a file? (for example bootstrap/tmux/client.c.patch) I'm trying to make some changes but the build system won't accept my patch ..

mordak commented 7 years ago

Sorry for the broken link - I updated the comment to point to the root of the QNX pkgsrc project.

I usually generate patches with diff -u <original> <modified> > patchfile.diff. Put the patchfile in the patches directory (eg bootstrap/tmux/patches/client.c.diff) and it should be automatically applied. If you need to pass a custom -p patch level you can do that, but the default is -p0. You can see the package_patch() routine in lib.sh.

KireinaHoro commented 7 years ago

Fine, thanks.

KireinaHoro commented 7 years ago

well, i found something interesting:

https://github.com/djbclark/bb10qnx

mordak commented 7 years ago

Oh that is interesting!

KireinaHoro commented 7 years ago

I'm trying to cross-compile bash and failed (after hacking on configure{,.in} for -3s and -lunix) because of SA_RESTART.

Strangely enough, I've succeeded in bootstrapping bash natively on Q10, when I hadn't ran into issues of SA_RESTART.

Wondering what made the difference..

mordak commented 7 years ago

Cool! Cross compiling is always a bit tricky, so who knows why it compiles natively and not cross. In any event, I am glad you got it working!

ghost commented 6 years ago

@KireinaHoro wondering if you had any further progress with Gentoo prefix? (Yeah I know the thread is 1.5 years old :wink:)

KireinaHoro commented 6 years ago

@vaskas I remember that I tried to bootstrap Gentoo Prefix on that Q10, but gave up later on. I recall that I gave up as Gentoo Prefix's bootstrap script didn't recognize QNX's CHOST, and refused to do things further.

I'm not using a BB10 system anymore, but if you're interested, go on! I think that some obstacles will come for porting Gentoo Prefix onto QNX, but things wouldn't be too hard probably.

Happy hacking!