This is an archive of the discontinued LLVM Phabricator instance.

Add CMAKE_EXECUTABLE_SUFFIX to build with Android toolchain on Windows.
ClosedPublic

Authored by chaoren on Apr 21 2015, 3:47 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

chaoren updated this revision to Diff 24181.Apr 21 2015, 3:47 PM
chaoren retitled this revision from to Add CMAKE_EXECUTABLE_SUFFIX to build with Android toolchain on Windows..
chaoren updated this object.
chaoren edited the test plan for this revision. (Show Details)
chaoren added reviewers: flackr, zturner, vharron.
chaoren added a subscriber: Unknown Object (MLST).

For some reason CMAKE_EXECUTABLE_SUFFIX is not actually set by cmake at this point, requiring a -DCMAKE_EXECUTABLE_SUFFIX=.exe flag. Perhaps we need to manually detect if the platform is Windows and set it?

flackr edited edge metadata.Apr 23 2015, 6:47 AM

I think we need to do the same in test/make/Makefile.rules for AR and OBJCOPY.

I'm curious why it's not getting set automatically, as far as I can tell it should be. It seems to be defined in the cmake source at Modules/Platform/Windows.cmake

zturner edited edge metadata.Apr 23 2015, 9:23 AM

Can we look into why it's not set automatically? If you litter some
messages around the cmake code that sets it, you should be able to figure
it out

This is probably why:

http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_TOOLCHAIN_FILE.html

a file which is read early in the CMake run

I guess we could just use the same fix as this: rL126219

chaoren updated this revision to Diff 24321.Apr 23 2015, 12:18 PM
chaoren edited edge metadata.

AR and OBJCOPY and workaround for CMAKE_EXECUTABLE_SUFFIX being undefined

I'm a little confused about why you're setting EXECUTABLE_SUFFIX in Android.cmake but checking CMAKE_EXECUTABLE_SUFFIX in Makefile.rules, shouldn't those both be CMAKE_EXECUTABLE_SUFFIX?

test/make/Makefile.rules
88 ↗(On Diff #24321)

Add $(CMAKE_EXECUTABLE_SUFFIX) here too. I believe libtool would need to be used if running the test suite from Windows against a remote mac target, just as we need to use ar for linking when targetting linux from mac.

I'm a little confused about why you're setting EXECUTABLE_SUFFIX in Android.cmake but checking CMAKE_EXECUTABLE_SUFFIX in Makefile.rules, shouldn't those both be CMAKE_EXECUTABLE_SUFFIX?

Nevermind, I've looked up many examples to the contrary. I'm still not sure though if CMAKE_EXECUTABLE_SUFFIX will pick up the EXECUTABLE_SUFFIX or if the examples are just using a separate variable because CMAKE_EXECUTABLE_SUFFIX is not supposed to be settable. Maybe we need to set EXECUTABLE_SUFFIX in Makefile.rules and use that, i.e. in Makefile.rules:
EXECUTABLE_SUFFIX ?= $(CMAKE_EXECUTABLE_SUFFIX)

then use $(EXECUTABLE_SUFFIX)

I think the reason CMAKE_EXECUTABLE_SUFFIX isn't being set is because Android.cmake is being run as a CMAKE_TOOLCHAIN_FILE.

Ugh, Makefile.rules is for Makefile rules not CMake rules so CMAKE_EXECUTABLE_SUFFIX makes no sense at all. Do you have Windows -> {Linux, OS X} tests running yet?

test/make/Makefile.rules
88 ↗(On Diff #24321)

These look like rules for a mac host instead of a mac target, since xcrun looks like an XCode command.

I think we need to do the same in test/make/Makefile.rules for AR and OBJCOPY.

Actually, I don't that'd be necessary. You can invoke executables on Windows without the extension, it's just that CMake actually checks if the executable exists. I originally made this CL because I wanted to cross compile the Android lldb-server on Windows (not terribly important, but sort of annoying if you have to switch to Linux while working on Windows -> Android). But there are other problems after this one, (e.g., Ninja generates response files with backslashes, but the ld.exe in the Android toolchain wants forward slashes). It's starting to look like more effort than it's worth.

chaoren updated this revision to Diff 24584.Apr 28 2015, 4:31 PM

CMake variable shouldn't appear in Makefile rules.

This revision was automatically updated to reflect the committed changes.