phhusson / Superuser

Keeping koush's Superuser fresh
GNU General Public License v3.0
423 stars 50 forks source link

Compile inline with AOSP n preview #51

Closed ikalkov closed 7 years ago

ikalkov commented 8 years ago

Can we extract those nested methods to allow compilation inline with AOSP?

external/Superuser/Superuser/jni/su/daemon.c:506:69: error: function definition is not allowed here auto void cb(void arg, int uid, const char src, const char *dst) {

external/Superuser/Superuser/jni/su/daemon.c:545:15: error: use of undeclared identifier 'cb' bind_foreach(cb, NULL);

external/Superuser/Superuser/jni/su/daemon.c:549:53: error: function definition is not allowed here auto void cb(void arg, int uid, const char path) {

external/Superuser/Superuser/jni/su/daemon.c:566:15: error: use of undeclared identifier 'cb' init_foreach(cb, NULL);

phhusson commented 8 years ago

Isn't it just of setting cflags properly?

Le 15 août 2016 23:50, "Igor Kalkov" notifications@github.com a écrit :

Can we extract those nested methods to allow compilation inline with AOSP?

external/Superuser/Superuser/jni/su/daemon.c:506:69: error: function definition is not allowed here auto void cb(void arg, int uid, const char src, const char *dst) {

external/Superuser/Superuser/jni/su/daemon.c:545:15: error: use of undeclared identifier 'cb' bind_foreach(cb, NULL);

external/Superuser/Superuser/jni/su/daemon.c:549:53: error: function definition is not allowed here auto void cb(void arg, int uid, const char path) {

external/Superuser/Superuser/jni/su/daemon.c:566:15: error: use of undeclared identifier 'cb' init_foreach(cb, NULL);

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/phhusson/Superuser/issues/51, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAOOhpDlJqpA86uRIwzVuE94X5vaxyYks5qgN8KgaJpZM4JkzqU .

ikalkov commented 8 years ago

To be honest, I have no idea :) Do you have a suggestion how it should be changed? I'd be happy to test it.

Until now I was using the original repo from koush. But as it seems pretty abandoned, I'd like to switch to something else for my AOSP N preview 5.

ikalkov commented 8 years ago

I've just tried this:

LOCAL_CFLAGS += -fnested-functions -z execstack -Wa,--execstack

in Superuser/jni/Android.mk, but I'm keep getting the same error message. Flags are taken from here: http://stackoverflow.com/questions/10577613/nested-functions-on-android-ndk

kelvinji2009 commented 7 years ago

@ikalkov Did you figure out how to fix this? I saw the same error. Thanks.

ikalkov commented 7 years ago

@kelvinji2009 No, but I've just found this commit: https://github.com/airend/Superuser/commit/3236a1c7aeae8610eaf2a5cd6d5c4c6d89c129ce I'll check it in the next days.

kelvinji2009 commented 7 years ago

@ikalkov Thanks for your reply. The commit is just for application build but not for su binary build(ndk-build).
My dev-env: OSX-10.11.6 NDK-r13(the latest version)

ikalkov commented 7 years ago

@kelvinji2009 I didn't test it myself yet, but the commit message is clearly about nested functions in the su binary:

Clang doesn't like nested functions, so use GCC temporarily, until su code is fixed.

There is also a change in the Android.mk file for the su module:

  LOCAL_MODULE := su
 +LOCAL_CLANG := false
kelvinji2009 commented 7 years ago

@ikalkov Yes, i have noticed it.And i have tried to modify the Superuser/jni/Android.mk as below

LOCAL_CLANG := false

But it does not work for me.

ikalkov commented 7 years ago

Hmm, there are other issues similar to this one, so I'll close it for now.