Halide icon indicating copy to clipboard operation
Halide copied to clipboard

Change generator target for using optional target flags for apps/blur

Open aankit-ca opened this issue 5 years ago • 8 comments

Without the change:

HL_TARGET=arm-64-android-hvx_128 make bin/arm-64-android/test

would have target=arm-64-android instead of arm-64-android-hvx_128

@dsharletg PTAL

aankit-ca avatar Dec 08 '20 22:12 aankit-ca

I'm not sure I like this fix -- it changes the pattern we use ~everywhere else in Make.

Why can't the user just do make bin/arm-64-android-hvx_128/test?

steven-johnson avatar Dec 08 '20 22:12 steven-johnson

This seemed like a quick fix for https://github.com/halide/Halide/issues/5523. For make bin/arm-64-android-hvx_128/test to work we will need: CXX-arm-32-android-hvx_128 in apps/support/Makefile and as DIllon pointed out having every combination of optional flag is not feasible. We can try breaking the HL_TARGET to see which CXX-* should be used in support/Makefile?

aankit-ca avatar Dec 08 '20 22:12 aankit-ca

I think this is a good change, but I think maybe we should go ahead and do it for all the apps?

The reason I think it is good is because the strategy used for selecting compilers in Makefile.inc doesn't work without it. We shouldn't need a different host compiler/linker flag for each possible combination of optional target flags, only the arch/OS.

Also, I think the current thing is simply broken. HL_TARGET=arm-64-android-hvx_128 make bin/arm-64-android/blur ignores HL_TARGET, that seems like a bug to me.

dsharletg avatar Dec 08 '20 23:12 dsharletg

I'll prep a PR to make this change uniformly across the apps.

steven-johnson avatar Dec 08 '20 23:12 steven-johnson

I don't think this is a good change. It's much better to distinguish between Halide targets using the make target. Messing with environment variables and having the makefile depend on them breaks make's dependency tracking when you're changing targets.

Most makefile rules should entirely ignore HL_TARGET. The only exception is generic targets like "test"

abadams avatar Dec 09 '20 00:12 abadams

Here's how to select compilers for cross-compilation without depending on env vars:

FILTER_CXX ?= c++
FILTER_LDFLAGS ?= -lwhatever
FILTER_CXX_FLAGS ?= -I whatever

... the generator rules ...

$(BIN)/%/filter: filter.cpp $(BIN)/%/my_halide_filter.a $(BIN)/%/runtime.a
	@mkdir -p $(@D)
	$(FILTER_CXX) $(FILTER_CXXFLAGS) -I$(BIN)/$* -Wall -O3 $^ -o $@ $(FILTER_LDFLAGS) 

# Tell make to use a different compiler and flags for some targets:
bin/arm-64-android/filter: FILTER_CXX=$(ARM64_CXX)
bin/arm-64-android/filter: FILTER_LDFLAGS=-ldl -llog -DHALIDE_NO_JPEG -DHALIDE_NO_PNG -static-libstdc++

# You can use wildcards too:
bin/arm-64-android-%/filter: FILTER_CXX=$(ARM64_CXX)
bin/arm-64-android-%/filter: FILTER_LDFLAGS=-ldl -llog -DHALIDE_NO_JPEG -DHALIDE_NO_PNG -static-libstdc++ -lEGL

abadams avatar Dec 09 '20 00:12 abadams

(See https://github.com/halide/Halide/pull/5539 for a complete suite of this change.)

steven-johnson avatar Dec 09 '20 00:12 steven-johnson

At this point it seems like this change isn't likely to happen, at least not in this form.

steven-johnson avatar Jan 25 '21 17:01 steven-johnson