Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7ce8bf07 authored by Sharjeel Khan's avatar Sharjeel Khan Committed by Gerrit Code Review
Browse files

Merge "Removed order file use flags from being passed to cflags" into main

parents 64876012 3c5d4c25
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -121,9 +121,9 @@ func (props *OrderfileProperties) getOrderfile(ctx BaseModuleContext) android.Op
}
}


func (props *OrderfileProperties) addInstrumentationProfileGatherFlags(ctx ModuleContext, flags Flags) Flags {
func (props *OrderfileProperties) addInstrumentationProfileGatherFlags(ctx ModuleContext, flags Flags) Flags {
	flags.Local.CFlags = append(flags.Local.CFlags, props.Orderfile.Cflags...)
	flags.Local.CFlags = append(flags.Local.CFlags, orderfileProfileFlag)
	flags.Local.CFlags = append(flags.Local.CFlags, orderfileProfileFlag)
	flags.Local.CFlags = append(flags.Local.CFlags, "-mllvm -enable-order-file-instrumentation")
	flags.Local.CFlags = append(flags.Local.CFlags, "-mllvm -enable-order-file-instrumentation")
	flags.Local.CFlags = append(flags.Local.CFlags, props.Orderfile.Cflags...)
	flags.Local.LdFlags = append(flags.Local.LdFlags, orderfileProfileFlag)
	flags.Local.LdFlags = append(flags.Local.LdFlags, orderfileProfileFlag)
	return flags
	return flags
}
}
@@ -140,7 +140,6 @@ func (props *OrderfileProperties) addLoadFlags(ctx ModuleContext, flags Flags) F
	orderFilePath := orderFile.Path()
	orderFilePath := orderFile.Path()
	loadFlags := props.loadOrderfileFlags(ctx, orderFilePath.String())
	loadFlags := props.loadOrderfileFlags(ctx, orderFilePath.String())


	flags.Local.CFlags = append(flags.Local.CFlags, loadFlags...)
	flags.Local.LdFlags = append(flags.Local.LdFlags, loadFlags...)
	flags.Local.LdFlags = append(flags.Local.LdFlags, loadFlags...)


	// Update CFlagsDeps and LdFlagsDeps so the module is rebuilt
	// Update CFlagsDeps and LdFlagsDeps so the module is rebuilt
+4 −27
Original line number Original line Diff line number Diff line
@@ -79,12 +79,6 @@ func TestOrderfileLoadSharedLibrary(t *testing.T) {


	libTest := result.ModuleForTests("libTest", "android_arm64_armv8-a_shared")
	libTest := result.ModuleForTests("libTest", "android_arm64_armv8-a_shared")


	// Check cFlags of orderfile-enabled module
	cFlags := libTest.Rule("cc").Args["cFlags"]
	if !strings.Contains(cFlags, expectedCFlag) {
		t.Errorf("Expected 'libTest' to load orderfile, but did not find %q in cflags %q", expectedCFlag, cFlags)
	}

	// Check ldFlags of orderfile-enabled module
	// Check ldFlags of orderfile-enabled module
	ldFlags := libTest.Rule("ld").Args["ldFlags"]
	ldFlags := libTest.Rule("ld").Args["ldFlags"]
	if !strings.Contains(ldFlags, expectedCFlag) {
	if !strings.Contains(ldFlags, expectedCFlag) {
@@ -150,12 +144,6 @@ func TestOrderfileLoadBinary(t *testing.T) {


	test := result.ModuleForTests("test", "android_arm64_armv8-a")
	test := result.ModuleForTests("test", "android_arm64_armv8-a")


	// Check cFlags of orderfile-enabled module
	cFlags := test.Rule("cc").Args["cFlags"]
	if !strings.Contains(cFlags, expectedCFlag) {
		t.Errorf("Expected 'test' to load orderfile, but did not find %q in cflags %q", expectedCFlag, cFlags)
	}

	// Check ldFlags of orderfile-enabled module
	// Check ldFlags of orderfile-enabled module
	ldFlags := test.Rule("ld").Args["ldFlags"]
	ldFlags := test.Rule("ld").Args["ldFlags"]
	if !strings.Contains(ldFlags, expectedCFlag) {
	if !strings.Contains(ldFlags, expectedCFlag) {
@@ -285,28 +273,17 @@ func TestOrderfileLoadPropagateStaticDeps(t *testing.T) {


	expectedCFlag := "-Wl,--symbol-ordering-file=toolchain/pgo-profiles/orderfiles/test.orderfile"
	expectedCFlag := "-Wl,--symbol-ordering-file=toolchain/pgo-profiles/orderfiles/test.orderfile"


	// Check cFlags of orderfile-enabled module
	// Check ldFlags of orderfile-enabled module
	libTest := result.ModuleForTests("libTest", "android_arm64_armv8-a_shared")
	libTest := result.ModuleForTests("libTest", "android_arm64_armv8-a_shared")


	cFlags := libTest.Rule("cc").Args["cFlags"]
	ldFlags := libTest.Rule("ld").Args["ldFlags"]
	if !strings.Contains(cFlags, expectedCFlag) {
	if !strings.Contains(ldFlags, expectedCFlag) {
		t.Errorf("Expected 'libTest' to load orderfile, but did not find %q in cflags %q", expectedCFlag, cFlags)
		t.Errorf("Expected 'libTest' to load orderfile, but did not find %q in ldFlags %q", expectedCFlag, ldFlags)
	}
	}


	// Check cFlags of the non-orderfile variant static libraries
	libFoo  := result.ModuleForTests("libFoo", "android_arm64_armv8-a_static")
	libFoo  := result.ModuleForTests("libFoo", "android_arm64_armv8-a_static")
	libBar  := result.ModuleForTests("libBar", "android_arm64_armv8-a_static")
	libBar  := result.ModuleForTests("libBar", "android_arm64_armv8-a_static")


	cFlags = libFoo.Rule("cc").Args["cFlags"]
	if strings.Contains(cFlags, expectedCFlag) {
		t.Errorf("Expected 'libFoo' not load orderfile, but did find %q in cflags %q", expectedCFlag, cFlags)
	}

	cFlags = libBar.Rule("cc").Args["cFlags"]
	if strings.Contains(cFlags, expectedCFlag) {
		t.Errorf("Expected 'libBar' not load orderfile, but did find %q in cflags %q", expectedCFlag, cFlags)
	}

	// Check dependency edge from orderfile-enabled module to non-orderfile variant static libraries
	// Check dependency edge from orderfile-enabled module to non-orderfile variant static libraries
	if !hasDirectDep(result, libTest.Module(), libFoo.Module()) {
	if !hasDirectDep(result, libTest.Module(), libFoo.Module()) {
		t.Errorf("libTest missing dependency on non-orderfile variant of libFoo")
		t.Errorf("libTest missing dependency on non-orderfile variant of libFoo")