at commit 205cccd0

1 # SPDX-License-Identifier: GPL-2.0-only
2 # drm/tegra depends on host1x, so if both drivers are built-in care must be
3 # taken to initialize them in the correct order. Link order is the only way
4 # to ensure this currently.
5 # Similarly, buddy must come first since it is used by other drivers.
6 obj-$(CONFIG_GPU_BUDDY) += buddy.o
7 obj-y += host1x/ drm/ vga/ tests/
8 obj-$(CONFIG_IMX_IPUV3_CORE) += ipu-v3/
9 obj-$(CONFIG_TRACE_GPU_MEM) += trace/
10
11 # nova-core and nova-drm are built from this Makefile so nova-drm's dependency
12 # on nova-core can be expressed as a plain Make prerequisite rather than a
13 # recursive sub-make. This is a temporary workaround until the Rust build
14 # system supports cross-crate dependencies natively.
15
16 obj-$(CONFIG_NOVA_CORE) += nova-core.o
17 nova-core-y := nova-core/nova_core.o nova-core/nova_core_exports.o
18
19 obj-$(CONFIG_DRM_NOVA) += nova-drm.o
20 nova-drm-y := drm/nova/nova.o
21
22 # Export Rust symbols from nova-core only if nova-drm actually references them.
23 nova-core-export-deps := $(if $(CONFIG_DRM_NOVA),$(obj)/drm/nova/nova.o)
24
25 rust_needed_exports = \
26 { $(if $(strip $(2)),$(NM) -u $(2);,) echo "__DEFINED_RUST_SYMBOLS__"; \
27 $(NM) -p --defined-only $(1); } | \
28 awk -v fmt='$(3)' ' \
29 /^__DEFINED_RUST_SYMBOLS__$$/ { defs = 1; next } \
30 !defs { if ($$NF ~ /^_R/) needed[$$NF] = 1; next } \
31 defs && $$2 ~ /(T|R|D|B)/ && $$3 ~ /^_R/ && \
32 $$3 !~ /_(init|cleanup)_module$$/ && \
33 $$3 !~ /__(pfx|cfi|odr_asan)/ && \
34 $$3 in needed { printf fmt, $$3 } \
35 '
36
37 quiet_cmd_exports = EXPORTS $@
38 cmd_exports = \
39 $(call rust_needed_exports,$<,$(nova-core-export-deps),EXPORT_SYMBOL_RUST_GPL(%s);\n) > $@
40
41 $(obj)/nova-core/exports_nova_core_generated.h: $(obj)/nova-core/nova_core.o $(nova-core-export-deps) FORCE
42 $(call if_changed,exports)
43
44 targets += nova-core/exports_nova_core_generated.h
45
46 $(obj)/nova-core/nova_core_exports.o: $(obj)/nova-core/exports_nova_core_generated.h
47 CFLAGS_nova-core/nova_core_exports.o := -I $(objtree)/$(obj)/nova-core
48
49 ifdef CONFIG_MODVERSIONS
50 # The C export shim declares Rust symbols as `extern int`, so reuse its export
51 # list but generate symbol CRCs from the Rust object instead of the shim's DWARF.
52 $(obj)/nova-core/nova_core_exports.o: private cmd_gensymtypes_c = \
53 $(call getexportsymbols,\1) | \
54 $(objtree)/scripts/gendwarfksyms/gendwarfksyms \
55 $(if $(KBUILD_GENDWARFKSYMS_STABLE), --stable) \
56 $(if $(KBUILD_SYMTYPES), --symtypes $(@:.o=.symtypes),) \
57 $(obj)/nova-core/nova_core.o
58 endif
59
60 # Output nova-core's crate metadata for use by nova-drm at compile time.
61 RUSTFLAGS_nova-core/nova_core.o += \
62 --emit=metadata=$(objtree)/$(obj)/nova-core/libnova_core.rmeta
63
64 # Allow nova-drm to import nova-core's types.
65 $(obj)/drm/nova/nova.o: $(obj)/nova-core/nova_core.o
66 RUSTFLAGS_drm/nova/nova.o := -L $(objtree)/$(obj)/nova-core --extern nova_core