Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/Modules/codegen-opt.test
T
vasilito cb424d7448 build: static patch-sanity linter (shift-left the malformed-patch class)
verify-patch-sanity.py validates every active recipe .patch has internally-
consistent hunk line counts — catching the 'malformed patch at line N' failure
at commit/CI/preflight time instead of hours into a cook. This cycle hit that
class three times (qtwaylandscanner, sddm, xwayland), each only discovered when
cookbook tried to apply the patch.

Running it across the repo found 29 latent malformed patches (validated against
GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22').
They were harmless only because they sit in vendored recipes (baked, not re-
applied) — but would fail on any version-bump re-derivation. --fix recounts the
hunk headers (body untouched) and repaired all 29.

Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test
(test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats
(empty placeholders, bare-@@ git hunks).
2026-08-01 05:13:02 +03:00

72 lines
3.5 KiB
Plaintext

RUN: rm -rf %t
REQUIRES: x86-registered-target
RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++ -fmodules -emit-module -fmodule-name=foo %S/Inputs/codegen-opt/foo.modulemap -o %t/foo.pcm
RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++ -fmodules -emit-module -fmodule-name=bar %S/Inputs/codegen-opt/bar.modulemap -o %t/bar.pcm -fmodule-file=%t/foo.pcm
RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/foo.pcm | FileCheck --check-prefix=FOO %s
RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/bar.pcm -fmodule-file=%t/foo.pcm | FileCheck --check-prefix=BAR-CMN --check-prefix=BAR %s
RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -fmodules -fmodule-file=%t/foo.pcm -fmodule-file=%t/bar.pcm %S/Inputs/codegen-opt/use.cpp | FileCheck --check-prefix=USE-CMN --check-prefix=USE %s
RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -O2 -disable-llvm-passes %t/foo.pcm | FileCheck --check-prefix=FOO %s
RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -O2 -disable-llvm-passes %t/bar.pcm -fmodule-file=%t/foo.pcm | FileCheck --check-prefix=BAR-CMN --check-prefix=BAR-OPT %s
RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -O2 -disable-llvm-passes -fmodules -fmodule-file=%t/foo.pcm -fmodule-file=%t/bar.pcm %S/Inputs/codegen-opt/use.cpp | FileCheck --check-prefix=USE-CMN --check-prefix=USE-OPT %s
FOO-NOT: comdat
FOO: $_Z3foov = comdat any
FOO: $_Z4foo2v = comdat any
FOO: $_ZZ3foovE1i = comdat any
FOO: @_ZZ3foovE1i = linkonce_odr global i32 0, comdat
FOO-NOT: {{comdat|define|declare}}
FOO: define{{.*}} void @_Z7foo_extv()
FOO-NOT: {{define|declare}}
FOO: define weak_odr void @_Z3foov() #{{[0-9]+}} comdat
FOO-NOT: {{define|declare}}
FOO: declare void @_Z2f1Ri(ptr
FOO-NOT: {{define|declare}}
Internal functions are not modularly code generated - they are
internal wherever they're used. This might not be ideal, but
continues to workaround/support some oddities that backwards
compatible modules have seen and supported in the wild. To remove
the duplication here, the internal functions would need to be
promoted to weak_odr, placed in comdat and given a new mangling -
this would be needed for the C++ Modules TS anyway.
FOO: define internal void @_ZL2f2v() #{{[0-9]+}}
FOO-NOT: {{define|declare}}
FOO: define weak_odr void @_Z4foo2v() #{{[0-9]+}} comdat
FOO-NOT: {{define|declare}}
BAR-CMN-NOT: comdat
BAR-CMN: $_Z3barv = comdat any
BAR-OPT: @_ZZ3foovE1i = linkonce_odr global i32 0, comdat
BAR-CMN-NOT: {{comdat|define|declare}}
BAR-CMN: define weak_odr void @_Z3barv() #{{[0-9]+}} comdat
BAR-CMN-NOT: {{define|declare}}
BAR: declare void @_Z3foov()
Include all the available_externally definitions required for bar (foo -> f2)
BAR-OPT: define available_externally void @_Z3foov()
BAR-CMN-NOT: {{define|declare}}
BAR-OPT: declare void @_Z2f1Ri(ptr
BAR-OPT-NOT: {{define|declare}}
BAR-OPT: define internal void @_ZL2f2v()
BAR-OPT-NOT: {{define|declare}}
USE-OPT: @_ZZ3foovE1i = linkonce_odr global i32 0, comdat
USE-CMN-NOT: {{comdat|define|declare}}
USE-CMN: define{{.*}} i32 @main()
USE-CMN-NOT: {{define|declare}}
USE: declare void @_Z3barv()
Include all the available_externally definitions required for main (bar -> foo -> f2)
USE-OPT: define available_externally void @_Z3barv()
USE-CMN-NOT: {{define|declare}}
USE-OPT: define available_externally void @_Z3foov()
USE-OPT-NOT: {{define|declare}}
USE-OPT: declare void @_Z2f1Ri(ptr
USE-OPT-NOT: {{define|declare}}
USE-OPT: define internal void @_ZL2f2v()
USE-OPT-NOT: {{define|declare}}