Skip to content

Commit

Permalink
Link -lm or -lm_hard for Android ARMv7.
Browse files Browse the repository at this point in the history
  • Loading branch information
xianyi committed Jul 5, 2017
1 parent a6515bb commit fa6a920
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Makefile.system
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,14 @@ else
CCOMMON_OPT += -mfloat-abi=hard
FCOMMON_OPT += -mfloat-abi=hard
endif

ifeq ($(OSNAME), Android)
ifeq ($(ARM_SOFTFP_ABI), 1)
EXTRALIB += -lm
else
EXTRALIB += -Wl,-lm_hard
endif
endif
endif

ifeq ($(ARCH), arm64)
Expand Down

4 comments on commit fa6a920

@ashwinyes
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi Xianyi.

Could you please explain why this was needed?

@xianyi
Copy link
Collaborator Author

@xianyi xianyi commented on fa6a920 Jul 5, 2017

Choose a reason for hiding this comment

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

OpenBLAS uses sqrt in some functions. e.g. dot.

If we didn't add -lm in generating shared library, the Android java codes will load OpenBLAS library failed.

@ashwinyes
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand why -lm is required.

Sorry if I was not clear.

I meant why do we need -lm_hard ? I think, If we are on a hard abi setup, -lm itself will take the hard abi math library.

Correct me if I am wrong.

@xianyi
Copy link
Collaborator Author

@xianyi xianyi commented on fa6a920 Jul 5, 2017

Choose a reason for hiding this comment

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

According to Android docs, we should link -lm_hard instead of -lm

Please sign in to comment.