kbuild: add support for ensuring headers are self-contained
Subsystems (4)
RFC 1/3 kbuild: add support for ensuring headers are self-contained
Sometimes it's useful to be able to explicitly ensure certain headers remain self-contained, i.e. that they are compilable as standalone units, by including and/or forward declaring everything they depend on.
Add special target header-test-y where individual Makefiles can add headers to be tested if CONFIG_HEADER_TEST is enabled. This will generate a dummy C file per header that gets built as part of extra-y.
--- Documentation/kbuild/makefiles.txt | 7 +++++++ init/Kconfig | 9 +++++++++ scripts/Makefile.build | 10 ++++++++++ scripts/Makefile.lib | 3 +++ 4 files changed, 29 insertions(+)
Documentation/kbuild/makefiles.txt +7 -0
@@ -1036,6 +1036,13 @@ When kbuild executes, the following steps are followed (roughly): In this example, extra-y is used to list object files that shall be built, but shall not be linked as part of built-in.a. + header-test-y + + header-test-y specifies headers (*.h) in the current directory that + should be compile tested to ensure they are self-contained, + i.e. compilable as standalone units. If CONFIG_HEADER_TEST is enabled, + this autogenerates dummy sources to include the headers, and builds them + as part of extra-y. --- 6.7 Commands useful for building a boot image
init/Kconfig +9 -0
@@ -95,6 +95,15 @@ config COMPILE_TEST here. If you are a user/distributor, say N here to exclude useless drivers to be distributed. +config HEADER_TEST + bool "Compile test headers that should be standalone compilable" + help + Compile test headers listed in header-test-y target to ensure they are + self-contained, i.e. compilable as standalone units. + + If you are a developer or tester and want to ensure the requested + headers are self-contained, say Y here. Otherwise, choose N. + config LOCALVERSION string "Local version - append to kernel release" help
scripts/Makefile.build +10 -0
@@ -291,6 +291,16 @@ quiet_cmd_cc_lst_c = MKLST $@ $(obj)/%.lst: $(src)/%.c FORCE $(call if_changed_dep,cc_lst_c) +# Dummy C sources for header test (header-test-y target) +# --------------------------------------------------------------------------- + +quiet_cmd_header_test = HDRTEST $@ + cmd_header_test = echo "\#include \"$(<F)\"" > $@ + +# FIXME: would be nice to be able to limit this implicit rule to header-test-y +$(obj)/%.header_test.c: $(src)/%.h FORCE + $(call if_changed,header_test) + # Compile assembler sources (.S) # ---------------------------------------------------------------------------
scripts/Makefile.lib +3 -0
@@ -66,6 +66,9 @@ extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y)) extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-)) endif +# Test self-contained headers +extra-$(CONFIG_HEADER_TEST) += $(patsubst %.h,%.header_test.o,$(header-test-y)) + # Add subdir path extra-y := $(addprefix $(obj)/,$(extra-y))
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC 2/3 drm/i915: ensure headers remain self-contained
Use the new header test facility.
--- drivers/gpu/drm/i915/Makefile | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/i915/Makefile +3 -0
@@ -204,3 +204,6 @@ i915-y += intel_lpe_audio.o obj-$(CONFIG_DRM_I915) += i915.o obj-$(CONFIG_DRM_I915_GVT_KVMGT) += gvt/kvmgt.o + +header-test-y := \ + i915_drv.h
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC 3/3 DO NOT MERGE: drm/i915: add failing header to header-test-y
In reply to Jani NikulaDemonstrate build failure on a header that is not self-contained.
--- drivers/gpu/drm/i915/Makefile | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/Makefile +1 -0
@@ -206,4 +206,5 @@ obj-$(CONFIG_DRM_I915) += i915.o obj-$(CONFIG_DRM_I915_GVT_KVMGT) += gvt/kvmgt.o header-test-y := \ + i915_fixed.h \ i915_drv.h
Signature · 1 line
2.20.1
Patchwork
CI✗ Fi.CI.SPARSE: warning for series starting with [RFC,1/3] kbuild: add support for ensuring headers are self-contained
In reply to Jani Nikula== Series Details ==
== Series Details ==
Series: series starting with [RFC,1/3] kbuild: add support for ensuring headers are self-contained
URL : https://patchwork.freedesktop.org/series/60738/
State : warning
== Summary ==
$ dim sparse origin/drm-tip Sparse version: v0.5.2 Commit: kbuild: add support for ensuring headers are self-contained +Error in reading or end of file.
Commit: drm/i915: ensure headers remain self-contained Okay!
Commit: DO NOT MERGE: drm/i915: add failing header to header-test-y Okay!
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for series starting with [RFC,1/3] kbuild: add support for ensuring headers are self-contained
In reply to Jani Nikula== Series Details ==
== Series Details ==
Series: series starting with [RFC,1/3] kbuild: add support for ensuring headers are self-contained
URL : https://patchwork.freedesktop.org/series/60738/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_6091 -> Patchwork_13027
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_13027:
### IGT changes ###
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.
* igt@gem_exec_basic@basic-blt:
- {fi-cml-u}: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-cml-u/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/fi-cml-u/igt@[email protected]
Known issues
------------
Here are the changes found in Patchwork_13027 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@amdgpu/amd_basic@userptr:
- fi-kbl-8809g: [PASS][3] -> [DMESG-WARN][4] ([fdo#108965])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-kbl-8809g/igt@amdgpu/[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/fi-kbl-8809g/igt@amdgpu/[email protected]
* igt@gem_exec_suspend@basic-s4-devices:
- fi-blb-e6850: [PASS][5] -> [INCOMPLETE][6] ([fdo#107718])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-blb-e6850/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/fi-blb-e6850/igt@[email protected]
* igt@i915_selftest@live_hangcheck:
- fi-apl-guc: [PASS][7] -> [INCOMPLETE][8] ([fdo#103927] / [fdo#110624])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-apl-guc/igt@i915_selftest@live_hangcheck.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/fi-apl-guc/igt@i915_selftest@live_hangcheck.html
#### Possible fixes ####
* igt@i915_pm_rpm@module-reload:
- fi-skl-6770hq: [FAIL][9] ([fdo#108511]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-skl-6770hq/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/fi-skl-6770hq/igt@[email protected]
* igt@i915_selftest@live_contexts:
- fi-bdw-gvtdvm: [DMESG-FAIL][11] ([fdo#110235]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-bdw-gvtdvm/igt@i915_selftest@live_contexts.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/fi-bdw-gvtdvm/igt@i915_selftest@live_contexts.html
* igt@kms_frontbuffer_tracking@basic:
- fi-hsw-peppy: [DMESG-WARN][13] ([fdo#102614]) -> [PASS][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-hsw-peppy/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/fi-hsw-peppy/igt@[email protected]
* igt@prime_vgem@basic-fence-flip:
- fi-ilk-650: [DMESG-WARN][15] ([fdo#106387]) -> [PASS][16] +1 similar issue
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-ilk-650/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/fi-ilk-650/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#106387]: https://bugs.freedesktop.org/show_bug.cgi?id=106387
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#108511]: https://bugs.freedesktop.org/show_bug.cgi?id=108511
[fdo#108965]: https://bugs.freedesktop.org/show_bug.cgi?id=108965
[fdo#110235]: https://bugs.freedesktop.org/show_bug.cgi?id=110235
[fdo#110624]: https://bugs.freedesktop.org/show_bug.cgi?id=110624
Participating hosts (50 -> 43)
------------------------------
Additional (1): fi-pnv-d510
Missing (8): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus
Build changes
-------------
* Linux: CI_DRM_6091 -> Patchwork_13027
CI_DRM_6091: 0ad895242a8e957336088625a9a6ba48ab838ec9 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4994: 555019f862c35f1619627761d6da21385be40920 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_13027: 01f606aff618932547f3d16320d0334dd8cf2989 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
01f606aff618 DO NOT MERGE: drm/i915: add failing header to header-test-y 916ec1935ae8 drm/i915: ensure headers remain self-contained 78ee211df3eb kbuild: add support for ensuring headers are self-contained
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for series starting with [RFC,1/3] kbuild: add support for ensuring headers are self-contained
In reply to Jani Nikula== Series Details ==
== Series Details ==
Series: series starting with [RFC,1/3] kbuild: add support for ensuring headers are self-contained
URL : https://patchwork.freedesktop.org/series/60738/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_6091_full -> Patchwork_13027_full
====================================================
Summary
-------
**SUCCESS**
No regressions found.
Known issues
------------
Here are the changes found in Patchwork_13027_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@kms_flip@flip-vs-expired-vblank:
- shard-glk: [PASS][1] -> [FAIL][2] ([fdo#105363])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-glk9/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-glk9/igt@[email protected]
* igt@kms_frontbuffer_tracking@fbcpsr-1p-pri-indfb-multidraw:
- shard-iclb: [PASS][3] -> [FAIL][4] ([fdo#103167]) +4 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-iclb7/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-iclb2/igt@[email protected]
* igt@kms_plane_alpha_blend@pipe-c-coverage-7efc:
- shard-skl: [PASS][5] -> [FAIL][6] ([fdo#108145] / [fdo#110403])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-skl1/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-skl7/igt@[email protected]
* igt@kms_plane_lowres@pipe-a-tiling-y:
- shard-iclb: [PASS][7] -> [FAIL][8] ([fdo#103166])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-iclb7/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-iclb1/igt@[email protected]
* igt@kms_psr@no_drrs:
- shard-iclb: [PASS][9] -> [FAIL][10] ([fdo#108341])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-iclb7/igt@kms_psr@no_drrs.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-iclb1/igt@kms_psr@no_drrs.html
* igt@kms_psr@psr2_no_drrs:
- shard-iclb: [PASS][11] -> [SKIP][12] ([fdo#109441])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-iclb2/igt@kms_psr@psr2_no_drrs.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-iclb7/igt@kms_psr@psr2_no_drrs.html
* igt@kms_vblank@pipe-c-ts-continuation-suspend:
- shard-apl: [PASS][13] -> [DMESG-WARN][14] ([fdo#108566]) +4 similar issues
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-apl1/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-apl8/igt@[email protected]
- shard-kbl: [PASS][15] -> [DMESG-WARN][16] ([fdo#108566])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-kbl1/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-kbl7/igt@[email protected]
#### Possible fixes ####
* igt@i915_pm_rpm@gem-mmap-gtt:
- shard-iclb: [INCOMPLETE][17] ([fdo#107713] / [fdo#108840]) -> [PASS][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-iclb7/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-iclb6/igt@[email protected]
* igt@i915_pm_rpm@reg-read-ioctl:
- shard-skl: [INCOMPLETE][19] ([fdo#107807]) -> [PASS][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-skl5/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-skl3/igt@[email protected]
* igt@i915_suspend@forcewake:
- shard-skl: [INCOMPLETE][21] ([fdo#104108] / [fdo#107773]) -> [PASS][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-skl9/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-skl3/igt@[email protected]
* igt@kms_frontbuffer_tracking@fbc-rgb565-draw-pwrite:
- shard-iclb: [FAIL][23] ([fdo#103167]) -> [PASS][24] +2 similar issues
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-iclb2/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-iclb5/igt@[email protected]
* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
- shard-apl: [DMESG-WARN][25] ([fdo#108566]) -> [PASS][26] +1 similar issue
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-apl1/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-apl8/igt@[email protected]
* igt@kms_plane@plane-panning-bottom-right-suspend-pipe-c-planes:
- shard-kbl: [DMESG-WARN][27] ([fdo#108566]) -> [PASS][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-kbl7/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-kbl2/igt@[email protected]
* igt@kms_plane_alpha_blend@pipe-b-coverage-7efc:
- shard-skl: [FAIL][29] ([fdo#108145] / [fdo#110403]) -> [PASS][30]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-skl6/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-skl3/igt@[email protected]
* igt@kms_plane_alpha_blend@pipe-c-constant-alpha-min:
- shard-skl: [FAIL][31] ([fdo#108145]) -> [PASS][32]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-skl5/igt@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-skl3/igt@[email protected]
* igt@kms_plane_cursor@pipe-a-primary-size-64:
- shard-iclb: [INCOMPLETE][33] ([fdo#107713]) -> [PASS][34] +1 similar issue
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-iclb1/igt@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-iclb1/igt@[email protected]
* igt@kms_psr@psr2_dpms:
- shard-iclb: [SKIP][35] ([fdo#109441]) -> [PASS][36] +1 similar issue
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-iclb7/igt@kms_psr@psr2_dpms.html
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-iclb2/igt@kms_psr@psr2_dpms.html
#### Warnings ####
* igt@gem_mmap_gtt@forked-big-copy:
- shard-iclb: [TIMEOUT][37] ([fdo#109673]) -> [INCOMPLETE][38] ([fdo#107713] / [fdo#109100])
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-iclb6/igt@[email protected]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-iclb4/igt@[email protected]
* igt@kms_chamelium@hdmi-hpd-after-suspend:
- shard-iclb: [INCOMPLETE][39] ([fdo#107713]) -> [SKIP][40] ([fdo#109284])
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/shard-iclb7/igt@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/shard-iclb1/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#104108]: https://bugs.freedesktop.org/show_bug.cgi?id=104108
[fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#107773]: https://bugs.freedesktop.org/show_bug.cgi?id=107773
[fdo#107807]: https://bugs.freedesktop.org/show_bug.cgi?id=107807
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108341]: https://bugs.freedesktop.org/show_bug.cgi?id=108341
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#108840]: https://bugs.freedesktop.org/show_bug.cgi?id=108840
[fdo#109100]: https://bugs.freedesktop.org/show_bug.cgi?id=109100
[fdo#109284]: https://bugs.freedesktop.org/show_bug.cgi?id=109284
[fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
[fdo#109673]: https://bugs.freedesktop.org/show_bug.cgi?id=109673
[fdo#110403]: https://bugs.freedesktop.org/show_bug.cgi?id=110403
Participating hosts (10 -> 10)
------------------------------
No changes in participating hosts
Build changes
-------------
* Linux: CI_DRM_6091 -> Patchwork_13027
CI_DRM_6091: 0ad895242a8e957336088625a9a6ba48ab838ec9 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4994: 555019f862c35f1619627761d6da21385be40920 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_13027: 01f606aff618932547f3d16320d0334dd8cf2989 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13027/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Jani Nikula (2019-05-16 20:48:16)
scripts/Makefile.lib extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y)) · line 70
Quoted 10 lines
scripts/Makefile.lib +2
-0@@ -66,6 +66,9 @@ extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y)) extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-)) endif +# Test self-contained headers +extra-$(CONFIG_HEADER_TEST) += $(patsubst %.h,%.header_test.o,$(header-test-y))
This didn't get pulled into clean-files.
clean-files-$(CONFIG_HEADER_TEST) += $(patsubst %.h,%.header_test.c,$(header-test-y)) ?
Not enough. Nor is clean-files-y +=...
And it should also be put into the global gitignore I think. -Chris
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 15 lines · Chris Wilson
Quoting Jani Nikula (2019-05-16 20:48:16)
scripts/Makefile.lib extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y)) · line 70
Quoted 10 lines
scripts/Makefile.lib +2
-0@@ -66,6 +66,9 @@ extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y)) extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-)) endif +# Test self-contained headers +extra-$(CONFIG_HEADER_TEST) += $(patsubst %.h,%.header_test.o,$(header-test-y))This didn't get pulled into clean-files.
Quoted 4 lines
clean-files-$(CONFIG_HEADER_TEST) += $(patsubst %.h,%.header_test.c,$(header-test-y)) ?
Not enough. Nor is clean-files-y +=...
The correct syntax is 'clean-files +=' instead of 'clean-files-y +='
If Kbuild supports this in the core Makefiles, we can add "-o -name '*.header_test.c'" to the top Makefile.
Quoted 1 line
And it should also be put into the global gitignore I think.
Documentation/dontdiff too.
Quoted 1 line
-Chris
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 94 lines · Jani Nikula
Sometimes it's useful to be able to explicitly ensure certain headers remain self-contained, i.e. that they are compilable as standalone units, by including and/or forward declaring everything they depend on.
Add special target header-test-y where individual Makefiles can add headers to be tested if
CONFIG_HEADER_TESTis enabled. This will generate a dummy C file per header that gets built as part of extra-y.Cc Chris Wilson <[email protected]>Cc Masahiro Yamada <[email protected]>Cc Michal Marek <[email protected]>Signed-off-by Jani Nikula <[email protected]>--- Documentation/kbuild/makefiles.txt | 7 +++++++ init/Kconfig | 9 +++++++++ scripts/Makefile.build | 10 ++++++++++ scripts/Makefile.lib | 3 +++ 4 files changed, 29 insertions(+)Documentation/kbuild/makefiles.txt +7
-0@@ -1036,6 +1036,13 @@ When kbuild executes, the following steps are followed (roughly): In this example, extra-y is used to list object files that shall be built, but shall not be linked as part of built-in.a. + header-test-y + + header-test-y specifies headers (*.h) in the current directory that + should be compile tested to ensure they are self-contained, + i.e. compilable as standalone units. If CONFIG_HEADER_TEST is enabled, + this autogenerates dummy sources to include the headers, and builds them + as part of extra-y. --- 6.7 Commands useful for building a boot imageinit/Kconfig +9
-0@@ -95,6 +95,15 @@ config COMPILE_TEST here. If you are a user/distributor, say N here to exclude useless drivers to be distributed. +config HEADER_TEST + bool "Compile test headers that should be standalone compilable" + help + Compile test headers listed in header-test-y target to ensure they are + self-contained, i.e. compilable as standalone units. + + If you are a developer or tester and want to ensure the requested + headers are self-contained, say Y here. Otherwise, choose N. + config LOCALVERSION string "Local version - append to kernel release" helpscripts/Makefile.build +10
-0@@ -291,6 +291,16 @@ quiet_cmd_cc_lst_c = MKLST $@ $(obj)/%.lst: $(src)/%.c FORCE $(call if_changed_dep,cc_lst_c) +# Dummy C sources for header test (header-test-y target) +# --------------------------------------------------------------------------- + +quiet_cmd_header_test = HDRTEST $@ + cmd_header_test = echo "\#include \"$(<F)\"" > $@ + +# FIXME: would be nice to be able to limit this implicit rule to header-test-y +$(obj)/%.header_test.c: $(src)/%.h FORCE + $(call if_changed,header_test) + # Compile assembler sources (.S) # ---------------------------------------------------------------------------scripts/Makefile.lib +3
-1@@ -66,6 +66,9 @@ extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y)) extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-)) endif +# Test self-contained headers +extra-$(CONFIG_HEADER_TEST) += $(patsubst %.h,%.header_test.o,$(header-test-y)) + # Add subdir path extra-y := $(addprefix $(obj)/,$(extra-y)) --
Quoted 2 lines
2.20.1
Thanks, probably we should do this.
At least, this check will be useful
for uapi headers since the kernel does not test the self-containedness of
exported headers, (then turned out be problematic later in user-space).
I will take a little time to considier how far we can extend the idea about "headers should be self-contained".
Thank you.
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 107 lines · Masahiro Yamada
Quoted 94 lines · Jani Nikula
Sometimes it's useful to be able to explicitly ensure certain headers remain self-contained, i.e. that they are compilable as standalone units, by including and/or forward declaring everything they depend on.
Add special target header-test-y where individual Makefiles can add headers to be tested if
CONFIG_HEADER_TESTis enabled. This will generate a dummy C file per header that gets built as part of extra-y.Cc Chris Wilson <[email protected]>Cc Masahiro Yamada <[email protected]>Cc Michal Marek <[email protected]>Signed-off-by Jani Nikula <[email protected]>--- Documentation/kbuild/makefiles.txt | 7 +++++++ init/Kconfig | 9 +++++++++ scripts/Makefile.build | 10 ++++++++++ scripts/Makefile.lib | 3 +++ 4 files changed, 29 insertions(+)Documentation/kbuild/makefiles.txt +7
-0@@ -1036,6 +1036,13 @@ When kbuild executes, the following steps are followed (roughly): In this example, extra-y is used to list object files that shall be built, but shall not be linked as part of built-in.a. + header-test-y + + header-test-y specifies headers (*.h) in the current directory that + should be compile tested to ensure they are self-contained, + i.e. compilable as standalone units. If CONFIG_HEADER_TEST is enabled, + this autogenerates dummy sources to include the headers, and builds them + as part of extra-y. --- 6.7 Commands useful for building a boot imageinit/Kconfig +9
-0@@ -95,6 +95,15 @@ config COMPILE_TEST here. If you are a user/distributor, say N here to exclude useless drivers to be distributed. +config HEADER_TEST + bool "Compile test headers that should be standalone compilable" + help + Compile test headers listed in header-test-y target to ensure they are + self-contained, i.e. compilable as standalone units. + + If you are a developer or tester and want to ensure the requested + headers are self-contained, say Y here. Otherwise, choose N. + config LOCALVERSION string "Local version - append to kernel release" helpscripts/Makefile.build +10
-0@@ -291,6 +291,16 @@ quiet_cmd_cc_lst_c = MKLST $@ $(obj)/%.lst: $(src)/%.c FORCE $(call if_changed_dep,cc_lst_c) +# Dummy C sources for header test (header-test-y target) +# --------------------------------------------------------------------------- + +quiet_cmd_header_test = HDRTEST $@ + cmd_header_test = echo "\#include \"$(<F)\"" > $@ + +# FIXME: would be nice to be able to limit this implicit rule to header-test-y +$(obj)/%.header_test.c: $(src)/%.h FORCE + $(call if_changed,header_test) + # Compile assembler sources (.S) # ---------------------------------------------------------------------------scripts/Makefile.lib +3
-1@@ -66,6 +66,9 @@ extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y)) extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-)) endif +# Test self-contained headers +extra-$(CONFIG_HEADER_TEST) += $(patsubst %.h,%.header_test.o,$(header-test-y)) + # Add subdir path extra-y := $(addprefix $(obj)/,$(extra-y)) --Quoted 2 lines
2.20.1
Thanks, probably we should do this.
At least, this check will be useful
for uapi headers since the kernel does not test the self-containedness of
exported headers, (then turned out be problematic later in user-space).
Quoted 3 lines
I will take a little time to considier how far we can extend the idea about "headers should be self-contained".
Thanks! Please let me know if/when you need further action from me, I won't post new versions until then.
BR,
Jani.
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
Hi Jani,
Quoted 8 lines · Jani Nikula
Quoted 5 lines
I will take a little time to considier
how far we can extend the idea about
"headers should be self-contained".Thanks! Please let me know if/when you need further action from me, I won't post new versions until then.
Could you send v2 with the following changes ?
[1] Could you rename *.header_test.c to *.hdrtest.c ? (I just thought .header_test.c was a bit too long.)
[2] %.hdrtest.c should not depend on the header
This will avoid unnecessary regeneration of *.hdrtest.c
quiet_cmd_header_test = HDRTEST $@
cmd_header_test = echo "\#include \"$*.h\"" > $@
$(obj)/%.hdrtest.c:
$(call cmd,header_test)
[3] Please add '*.hdrtest.c' to .gitignore, Documentation/dontdiff
[4] Please add '*.hdrtest.c' to 'make clean' (around line 1640 of top Makefile)
Signature · 2 lines
Best Regards Masahiro Yamada
Hi Jani
Quoted 7 lines
Sometimes it's useful to be able to explicitly ensure certain headers remain self-contained, i.e. that they are compilable as standalone units, by including and/or forward declaring everything they depend on.
Add special target header-test-y where individual Makefiles can add headers to be tested if
CONFIG_HEADER_TESTis enabled. This will generate a dummy C file per header that gets built as part of extra-y.
Very useful, thanks.
I have cooked up something ad-hoc a couple of times but having it as a standard feature in the build system is much better.
The we can let some of our infrastructure pick up an issues automatically.
Quoted 17 lines
Cc Chris Wilson <[email protected]>Cc Masahiro Yamada <[email protected]>Cc Michal Marek <[email protected]>Signed-off-by Jani Nikula <[email protected]>--- Documentation/kbuild/makefiles.txt | 7 +++++++ init/Kconfig | 9 +++++++++ scripts/Makefile.build | 10 ++++++++++ scripts/Makefile.lib | 3 +++ 4 files changed, 29 insertions(+)Documentation/kbuild/makefiles.txt +0
-0
Documentation/kbuild/makefiles.txt When kbuild executes, the following steps are followed (roughly): · line 1045
Quoted 10 lines
Documentation/kbuild/makefiles.txt +7
-0@@ -1036,6 +1036,13 @@ When kbuild executes, the following steps are followed (roughly): In this example, extra-y is used to list object files that shall be built, but shall not be linked as part of built-in.a. + header-test-y + + header-test-y specifies headers (*.h) in the current directory that + should be compile tested to ensure they are self-contained, + i.e. compilable as standalone units. If CONFIG_HEADER_TEST is enabled, + this autogenerates dummy sources to include the headers, and builds them + as part of extra-y.
Do we want to restrict this to current directory only? Sometimes we could use this for headers in include/ but let it trigger for the relevant subsystem.
So for example drivers/gpu/drm/Makefile will include the rules for all headers in include/drm/*
The alternative would be Makefiles (of Kbuild files) scattered in the directories with headers and then some infrastructure to visit those.
Follow patch extend the header-test feature to work with headers in include/
Example:
# Header files from this directory
header-test-y += drm_crtc_helper_internal.h
header-test-y += drm_crtc_internal.h
..
.
# Header files from include/drm
header-test-y += drm/amd_asic_type.h
header-test-y += drm/ati_pcigart.h
...
In the patch $* is used to get the "stem" from the pattern. This is the filname of the header file without extension.
Sam
scripts/Makefile.build +3 -4
@@ -295,11 +295,10 @@ $(obj)/%.lst: $(src)/%.c FORCE # --------------------------------------------------------------------------- quiet_cmd_header_test = HDRTEST $@ - cmd_header_test = echo "\#include \"$(<F)\"" > $@ + cmd_header_test = echo "\#include <$(2).h>" > $@ -# FIXME: would be nice to be able to limit this implicit rule to header-test-y -$(obj)/%.header_test.c: $(src)/%.h FORCE - $(call if_changed,header_test) +$(obj)/%.header_test.c: + $(call cmd,header_test,$*) # Compile assembler sources (.S) # ---------------------------------------------------------------------------
Hi Sam,
Quoted 50 lines · Sam Ravnborg
Hi Jani
Quoted 7 lines
Sometimes it's useful to be able to explicitly ensure certain headers remain self-contained, i.e. that they are compilable as standalone units, by including and/or forward declaring everything they depend on.
Add special target header-test-y where individual Makefiles can add headers to be tested if
CONFIG_HEADER_TESTis enabled. This will generate a dummy C file per header that gets built as part of extra-y.Very useful, thanks.
I have cooked up something ad-hoc a couple of times but having it as a standard feature in the build system is much better.
The we can let some of our infrastructure pick up an issues automatically.Quoted 17 lines
Cc Chris Wilson <[email protected]>Cc Masahiro Yamada <[email protected]>Cc Michal Marek <[email protected]>Signed-off-by Jani Nikula <[email protected]>--- Documentation/kbuild/makefiles.txt | 7 +++++++ init/Kconfig | 9 +++++++++ scripts/Makefile.build | 10 ++++++++++ scripts/Makefile.lib | 3 +++ 4 files changed, 29 insertions(+)Documentation/kbuild/makefiles.txt +0
-0Documentation/kbuild/makefiles.txt When kbuild executes, the following steps are followed (roughly): · line 1045
Quoted 10 lines
Documentation/kbuild/makefiles.txt +7
-0@@ -1036,6 +1036,13 @@ When kbuild executes, the following steps are followed (roughly): In this example, extra-y is used to list object files that shall be built, but shall not be linked as part of built-in.a. + header-test-y + + header-test-y specifies headers (*.h) in the current directory that + should be compile tested to ensure they are self-contained, + i.e. compilable as standalone units. If CONFIG_HEADER_TEST is enabled, + this autogenerates dummy sources to include the headers, and builds them + as part of extra-y.Do we want to restrict this to current directory only? Sometimes we could use this for headers in
include/but let it trigger for the relevant subsystem.
So for exampledrivers/gpu/drm/Makefilewill include the rules for all headers ininclude/drm/*
Quoted 6 lines
The alternative would be Makefiles (of
Kbuildfiles) scattered in the directories with headers and then some infrastructure to visit those.Follow patch extend the header-test feature to work with headers in
include/
Following the obj-y pattern,
I want to make header-test-y relative to $(obj).
Quoted 4 lines
Example:
# Header files from this directory
header-test-y +=drm_crtc_helper_internal.h
header-test-y +=drm_crtc_internal.h
These are described in drivers/gpu/drm/Makefile.
Quoted 5 lines
..
.
# Header files frominclude/drm
header-test-y +=drm/amd_asic_type.h
header-test-y +=drm/ati_pcigart.h
These are described in $(srctree)/include/Makefile.
Quoted 20 lines
...
In the patch $* is used to get the "stem" from the pattern. This is the filname of the header file without extension.
Sam
scripts/Makefile.build +0
-1@@ -295,11 +295,10 @@ $(obj)/%.lst: $(src)/%.c FORCE # --------------------------------------------------------------------------- quiet_cmd_header_test = HDRTEST $@ - cmd_header_test = echo "\#include \"$(<F)\"" > $@
scripts/Makefile.build $(obj)/%.lst: $(src)/%.c FORCE · line 304
Quoted 10 lines
scripts/Makefile.build +3
-3+ cmd_header_test = echo "\#include <$(2).h>" > $@ -# FIXME: would be nice to be able to limit this implicit rule to header-test-y -$(obj)/%.header_test.c: $(src)/%.h FORCE - $(call if_changed,header_test) +$(obj)/%.header_test.c: + $(call cmd,header_test,$*) # Compile assembler sources (.S) # ---------------------------------------------------------------------------
Agree, this is much better,
and it is what scripts/Makefile.asm-generic does.
But, you do not need to pass '$*' via the argument.
I prefer this:
quiet_cmd_header_test = HDRTEST $@
cmd_header_test = echo "\#include \"$*.h\"" > $@
$(obj)/%.header_test.c:
$(call cmd,header_test)
Signature · 6 lines
Best Regards Masahiro Yamada _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi Masahiro/Jani.
Quoted 3 lines
Following the obj-y pattern,
I want to make header-test-y relative to $(obj).
I also considered this and agree this is better.
Otherwise we end up with a spaghetti of dependencies across the tree.
What I made just fit the purpose I had that day,
which is no excuse for bad design.
Quoted 7 lines
I prefer this:
quiet_cmd_header_test= HDRTEST $@cmd_header_test = echo "\#include \"$*.h\"" > $@$(obj)/%.header_test.c:
$(call cmd,header_test)
Even better - good.
We call it HDRTEST - so why not just go for that name:
hdrtest-y += headerfile.h
??
The current proposal with "header-test-y" hurts the eye a little with two '-', and all other variables uses only one '-' as is today. (generic-y, obj-y etc).
This is bikeshedding but is was itcing me a little.
Sam
Hi Sam, Jani,
Quoted 28 lines · Sam Ravnborg
Hi Masahiro/Jani.
Quoted 3 lines
Following the obj-y pattern,
I want to make header-test-y relative to $(obj).I also considered this and agree this is better.
Otherwise we end up with a spaghetti of dependencies across the tree.
What I made just fit the purpose I had that day,
which is no excuse for bad design.Quoted 7 lines
I prefer this:
quiet_cmd_header_test= HDRTEST $@cmd_header_test = echo "\#include \"$*.h\"" > $@$(obj)/%.header_test.c:
$(call cmd,header_test)Even better - good.
We call it HDRTEST - so why not just go for that name:
hdrtest-y += headerfile.h
Quoted 7 lines
??
The current proposal with "header-test-y" hurts the eye a little with two '-', and all other variables uses only one '-' as is today. (generic-y, obj-y etc).
This is bikeshedding but is was itcing me a little.
I do not have a strong opinion.
I leave it to Jani. Either is fine with me.
There are variables that contain two '-'.
'no-clean-files', 'subdir-ccflags-y', etc.
--
Best Regards
Masahiro Yamada
Patchwork
CI✗ Fi.CI.BAT: failure for series starting with [RFC,1/3] kbuild: add support for ensuring headers are self-contained (rev2)
In reply to Jani Nikula== Series Details ==
== Series Details ==
Series: series starting with [RFC,1/3] kbuild: add support for ensuring headers are self-contained (rev2)
URL : https://patchwork.freedesktop.org/series/60738/
State : failure
== Summary ==
Applying: kbuild: add support for ensuring headers are self-contained Using index info to reconstruct a base tree...
M scripts/Makefile.build
Falling back to patching base and 3-way merge...
Auto-merging scripts/Makefile.build
CONFLICT (content): Merge conflict in scripts/Makefile.build
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch' to see the failed patch Patch failed at 0001 kbuild: add support for ensuring headers are self-contained When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx