Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clightning support #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add clightning support #21

wants to merge 1 commit into from

Conversation

greenaddress
Copy link
Owner

No description provided.

@lvaccaro
Copy link
Contributor

ack 16f91f2

@lvaccaro lvaccaro mentioned this pull request Dec 18, 2019
Copy link

@cdecker cdecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't really tried this, but from reviewing the changes it seems to work. I guess the main complication is that the configurator is not really well-suited for cross-compilation targets, since it assumes the platform it runs on is the platform the final binary will run on, and there is no way to sideload the config from another system yet.

Some of these patches should be upstreamed, which would reduce the maintenance burden and improve c-lightning's own support. I added comments to that effect where necessary 😉

All in all excellent work @lvaccaro, that's quite some sleuthing to get all the piece to fit 👍

Comment on lines +82 to +84
sed -i 's/$CC ${CWARNFLAGS-$BASE_WARNFLAGS} $CDEBUGFLAGS $COPTFLAGS -o $CONFIGURATOR $CONFIGURATOR.c/$CONFIGURATOR_CC ${CWARNFLAGS-$BASE_WARNFLAGS} $CDEBUGFLAGS $COPTFLAGS -o $CONFIGURATOR $CONFIGURATOR.c/g' configure
sed -i 's/-Wno-maybe-uninitialized/-Wno-uninitialized/g' configure
./configure CONFIGURATOR_CC=${CONFIGURATOR_CC} --prefix=${LNBUILDROOT} --disable-developer --disable-compat --disable-valgrind --enable-static
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a nice patch to upstream. The configurator is always a bit weird in cross-compile scenarios fwiw

Comment on lines +88 to +89
sed "s'NDKCOMPILER'${CC}'" /repo/lightning-config.vars > config.vars
sed "s'NDKCOMPILER'${CC}'" /repo/lightning-config.h > ccan/config.h
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange switch of sed separators. Any particular reason for not continuing to use / like above?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code used to contain slashes in sed, that was fixed but the separator wasn't changed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, sed syntax could be aligned in the entire script. I don't really like using sed on pre-generated headers file, but it is a dirty trick to don't use qemu in the CI.

Comment on lines +8 to +14
/* Needed for Glibc like endiness check */
+#ifndef __LITTLE_ENDIAN
#define __LITTLE_ENDIAN 1234
+#endif
+#ifndef __BIG_ENDIAN
#define __BIG_ENDIAN 4321
+#endif
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this change required for? It might need upstreaming as well, since we should be able to detect endiannes reliably.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point we should try to give it a go without

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configurator has an option about HAVE_BIG_ENDIAN, but I am not sure solve the issue during building ccan https://github.com/ElementsProject/lightning/blob/359433f374472a6128993bbaace2c1c7c62ee107/ccan/tools/configurator/configurator.c#L174

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue imho is that the configurator is running on the host architecture and will thus use the host endianness instead of the target arch's endianness. Maybe ElementsProject/lightning#3464 could be used to run the configurator in qemu emulating the target arch, thus picking up the correct values automatically?

Comment on lines +9 to +12
- strcpy(addr.sun_path, rpc_filename);
+ addr.sun_path[0] = '\0';
+ strcpy(addr.sun_path + 1, rpc_filename);
addr.sun_family = AF_UNIX;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite follow this change. addr.sun_path now has a string terminator at the beginning?

Copy link
Contributor

@lvaccaro lvaccaro Dec 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch is not related to the building process, but related to use c-lightning in an android device that doesn't support communication using traditional AF_UNIX socket file. The '\0' swap allows to use abstract namespace socket for inter-process communication (also available on linux kernel that holds in its memory space). I think there are some security concerns on accessing them.

Comment on lines +9 to +10
-CFLAGS = $(CPPFLAGS) $(CWARNFLAGS) $(CDEBUGFLAGS) $(COPTFLAGS) -I $(CCANDIR) $(EXTERNAL_INCLUDE_FLAGS) -I . -I/usr/local/include $(FEATURES) $(COVFLAGS) $(DEV_CFLAGS) -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS $(PIE_CFLAGS) $(COMPAT_CFLAGS) -DBUILD_ELEMENTS=1
+CFLAGS = $(CPPFLAGS) $(CWARNFLAGS) $(CDEBUGFLAGS) $(COPTFLAGS) -I $(CCANDIR) $(EXTERNAL_INCLUDE_FLAGS) -I . -I$(PREFIX)/include $(FEATURES) $(COVFLAGS) $(DEV_CFLAGS) -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS $(PIE_CFLAGS) $(COMPAT_CFLAGS) -DBUILD_ELEMENTS=1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could definitely be upstreamed.

@lvaccaro
Copy link
Contributor

config.vars is mostly used by configurator to generate the header files (in this PR the headers files are pre-generated). On the other side, in Makefile there are some existence checks on config.vars, so if you prefer to remove vars file from PR, Makefile needs to be patched.

@lvaccaro
Copy link
Contributor

commit lvaccaro@68fe1b3 should align sed commands in order to use the same syntax

@darosior
Copy link

FWIW I tried this and succesfully ran C-lightning on my phone. I'll submit a patchset for the new version.

@jsarenik
Copy link

@greenaddress ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants