Default state of LOCAL_ALLOW_UNDEFINED_SYMBOLS

468 views
Skip to first unread message

Divkis

unread,
Feb 2, 2010, 1:49:38 AM2/2/10
to android-ndk
Hi,
I see that as per Android.mk docuemtation this flag _IS_ _ENABLED_
by default but when I build my shared library it doesn't complain of a
dozen undefined symbols that exist.

I have tried enabling it explicitly by defining, the following in my
Android.mk file which builds the shared library, but this also doesn't
help.

LOCAL_ALLOW_UNDEFINED_SYMBOLS=false

When I explicitly pass the -Wl,-no-undefined to build my shared
library (as shown below) then it __DOES__ complain.

build/prebuilt/windows/arm-eabi-4.2.1/bin/arm-eabi-gcc -nostdlib -Wl,-
no-undefined -Wl,-soname,libmyapp.so -Wl,-shared,-Bsymbolic out/apps/
myapp//objs/app.o -Wl,--whole-archive -Wl,--no-whole-archive build/
platforms/android-3/arch-arm/usr/lib/libc.so build/platforms/android-3/
arch-arm/usr/lib/libstdc++.so build/platforms/android-3/arch-arm/usr/
lib/libm.so -Wl,-rpath-link=build/platforms/android-3/arch-arm/usr/
lib /cygdrive/c/install/android-ndk-1.6_r1/build/prebuilt/windows/arm-
eabi-4.2.1/bin/../lib/gcc/arm-eabi/4.2.1/interwork/libgcc.a -o out/
apps/eyeugo//libmyapp.so

Could someone please guide me what could be the cause of overridden
flags and how to solve this?

Thanks in advance,
Divkis

David Turner

unread,
Feb 2, 2010, 2:21:05 PM2/2/10
to andro...@googlegroups.com
I cannot reproduce this. But there seems to be a bug in build/core/clear-vars.mk that resets the value of LOCAL_NO_UNDEFINED_SYMBOLS
(instead of LOCAL_ALLOW_UNDEFINED_SYMBOLS) when you include $(CLEAR_VARS).

The -Wl,-no-undefined flag should be added to your command line as long as LOCAL_ALLOW_UNDEFINED_SYMBOLS is undefined or empty
(see line 65 of build/core/build-binary.mk)

So, if you defined LOCAL_ALLOW_UNDEFINED_SYMBOLS in another module, the definition sticks after the include $(CLEAR_VARS).

One fix is to modify build/core/clear-vars.mk to reset the correct variable.

Hope this helps


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Divkis

unread,
Feb 3, 2010, 3:47:55 AM2/3/10
to android-ndk
Hi David,
I think I found the trouble. Please see my reply
inlined below:

On Feb 3, 12:21 am, David Turner <di...@android.com> wrote:
> I cannot reproduce this. But there seems to be a bug in build/core/
> clear-vars.mk that resets the value of LOCAL_NO_UNDEFINED_SYMBOLS
> (instead of LOCAL_ALLOW_UNDEFINED_SYMBOLS) when you include $(CLEAR_VARS).

I think this should not be a problem as the intention of clear vars is
to clear all the variables.

> The -Wl,-no-undefined flag should be added to your command line as long as
> LOCAL_ALLOW_UNDEFINED_SYMBOLS is undefined or empty
> (see line 65 of build/core/build-binary.mk)

I see that the code in build/core/build-binary.mk is this:

ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),)
LOCAL_LDFLAGS := $(LOCAL_LDFLAGS) $($(my)NO_UNDEFINED_LDFLAGS)
endif

which means that it doesn't check what the value of
LOCAL_ALLOW_UNDEFINED_SYMBOLS is, instead it checks if it empty or
not. In my case I was under the assumption that defining it like shown
below should make it false, while it doesn't matter what value you
assign to this variable.

LOCAL_ALLOW_UNDEFINED_SYMBOLS := false


I see this as a problem in documentation which states the following:

"
LOCAL_ALLOW_UNDEFINED_SYMBOLS
By default, any undefined reference encountered when trying to
build
a shared library will result in an "undefined symbol" error. This
is a
great help to catch bugs in your source code.

However, if for some reason you need to disable this check, set
this
variable to 'true'. Note that the corresponding shared library may
fail
to load at runtime.
"

The paragraph above should be changed to reflect what is being tested
in the build-binary.mk. Also it might be a good idea to document the
LOCAL_NO_UNDEFINED_SYMBOLS.


Thanks a lot for you help,
Regards,
Divkis

Reply all
Reply to author
Forward
0 new messages