MaskRay updated this revision to Diff 317985. MaskRay retitled this revision from "Makefile.rules: Avoid redundant .d generation and make restart" to "Makefile.rules: Avoid redundant .d generation (make restart) and inline archive rule to the only test". MaskRay edited the summary of this revision. MaskRay added a comment.
Use $(AR) Remove more ARCHIVE_NAME Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D94890/new/ https://reviews.llvm.org/D94890 Files: lldb/packages/Python/lldbsuite/test/make/Makefile.rules lldb/test/API/functionalities/archives/Makefile
Index: lldb/test/API/functionalities/archives/Makefile =================================================================== --- lldb/test/API/functionalities/archives/Makefile +++ lldb/test/API/functionalities/archives/Makefile @@ -1,7 +1,13 @@ -C_SOURCES := main.c - +C_SOURCES := main.c a.c b.c +EXE := # Define a.out explicitly MAKE_DSYM := NO -ARCHIVE_NAME := libfoo.a -ARCHIVE_C_SOURCES := a.c b.c + +all: a.out + +a.out: main.o libfoo.a + $(LD) $(LDFLAGS) $^ -o $@ + +libfoo.a: a.o b.o + $(AR) $(ARFLAGS) $@ $^ include Makefile.rules Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules =================================================================== --- lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -26,15 +26,13 @@ # SPLIT_DEBUG_SYMBOLS := YES # CROSS_COMPILE := # USE_PRIVATE_MODULE_CACHE := YES -# -# And test/functionalities/archives/Makefile: -# MAKE_DSYM := NO -# ARCHIVE_NAME := libfoo.a -# ARCHIVE_C_SOURCES := a.c b.c # Uncomment line below for debugging shell commands # SHELL = /bin/sh -x +# Suppress built-in suffix rules. We explicitly define rules for %.o. +.SUFFIXES: + SRCDIR := $(shell dirname $(firstword $(MAKEFILE_LIST))) BUILDDIR := $(shell pwd) MAKEFILE_RULES := $(lastword $(MAKEFILE_LIST)) @@ -477,42 +475,6 @@ endif endif -#---------------------------------------------------------------------- -# Check if we have any C source files for archive -#---------------------------------------------------------------------- -ifneq "$(strip $(ARCHIVE_C_SOURCES))" "" - ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_C_SOURCES:.c=.o)) -endif - -#---------------------------------------------------------------------- -# Check if we have any C++ source files for archive -#---------------------------------------------------------------------- -ifneq "$(strip $(ARCHIVE_CXX_SOURCES))" "" - ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_CXX_SOURCES:.cpp=.o)) - CXX = $(call cxx_compiler,$(CC)) - LD = $(call cxx_linker,$(CC)) -endif - -#---------------------------------------------------------------------- -# Check if we have any ObjC source files for archive -#---------------------------------------------------------------------- -ifneq "$(strip $(ARCHIVE_OBJC_SOURCES))" "" - ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_OBJC_SOURCES:.m=.o)) - LDFLAGS +=-lobjc -endif - -#---------------------------------------------------------------------- -# Check if we have any ObjC++ source files for archive -#---------------------------------------------------------------------- -ifneq "$(strip $(ARCHIVE_OBJCXX_SOURCES))" "" - ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_OBJCXX_SOURCES:.mm=.o)) - CXX = $(call cxx_compiler,$(CC)) - LD = $(call cxx_linker,$(CC)) - ifeq "$(findstring lobjc,$(LDFLAGS))" "" - LDFLAGS +=-lobjc - endif -endif - ifeq ($(findstring clang, $(CXX)), clang) CXXFLAGS += --driver-mode=g++ endif @@ -534,8 +496,8 @@ #---------------------------------------------------------------------- ifneq "$(DYLIB_NAME)" "" ifeq "$(DYLIB_ONLY)" "" -$(EXE) : $(OBJECTS) $(ARCHIVE_NAME) $(DYLIB_FILENAME) - $(LD) $(OBJECTS) $(ARCHIVE_NAME) -L. -l$(DYLIB_NAME) $(LDFLAGS) -o "$(EXE)" +$(EXE) : $(OBJECTS) $(DYLIB_FILENAME) + $(LD) $(OBJECTS) -L. -l$(DYLIB_NAME) $(LDFLAGS) -o "$(EXE)" ifneq "$(CODESIGN)" "" $(CODESIGN) -s - "$(EXE)" endif @@ -543,8 +505,8 @@ EXE = $(DYLIB_FILENAME) endif else -$(EXE) : $(OBJECTS) $(ARCHIVE_NAME) - $(LD) $(OBJECTS) $(LDFLAGS) $(ARCHIVE_NAME) -o "$(EXE)" +$(EXE) : $(OBJECTS) + $(LD) $(OBJECTS) $(LDFLAGS) -o "$(EXE)" ifneq "$(CODESIGN)" "" $(CODESIGN) -s - "$(EXE)" endif @@ -566,19 +528,6 @@ endif endif -#---------------------------------------------------------------------- -# Make the archive -#---------------------------------------------------------------------- -ifneq "$(ARCHIVE_NAME)" "" -ifeq "$(OS)" "Darwin" -$(ARCHIVE_NAME) : $(ARCHIVE_OBJECTS) - $(AR) $(ARFLAGS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS) - $(RM) $(ARCHIVE_OBJECTS) -else -$(ARCHIVE_NAME) : $(foreach ar_obj,$(ARCHIVE_OBJECTS),$(ARCHIVE_NAME)($(ar_obj))) -endif -endif - #---------------------------------------------------------------------- # Make the dylib #---------------------------------------------------------------------- @@ -628,12 +577,22 @@ # Make the precompiled header and compile C++ sources against it #---------------------------------------------------------------------- -#ifneq "$(PCH_OUTPUT)" "" +ifneq "$(PCH_OUTPUT)" "" $(PCH_OUTPUT) : $(PCH_CXX_SOURCE) $(CXX) $(CXXFLAGS) -x c++-header -o $@ $< -%.o : %.cpp $(PCH_OUTPUT) - $(CXX) $(PCHFLAGS) $(CXXFLAGS) -c -o $@ $< -#endif +endif + +%.o: %.c %.d + $(CC) $(CFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $< + +%.o: %.cpp %.d $(PCH_OUTPUT) + $(CXX) $(PCHFLAGS) $(CXXFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $< + +%.o: %.m %.d + $(CC) $(CFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $< + +%.o: %.mm %.d + $(CXX) $(CXXFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $< #---------------------------------------------------------------------- # Automatic variables based on items already entered. Below we create @@ -642,42 +601,20 @@ # files by replacing all .c files with .d. #---------------------------------------------------------------------- PREREQS := $(OBJECTS:.o=.d) -DWOS := $(OBJECTS:.o=.dwo) $(ARCHIVE_OBJECTS:.o=.dwo) +DWOS := $(OBJECTS:.o=.dwo) ifneq "$(DYLIB_NAME)" "" DYLIB_PREREQS := $(DYLIB_OBJECTS:.o=.d) DYLIB_DWOS := $(DYLIB_OBJECTS:.o=.dwo) endif -#---------------------------------------------------------------------- -# Rule for Generating Prerequisites Automatically using .d files and -# the compiler -MM option. The -M option will list all system headers, -# and the -MM option will list all non-system dependencies. -#---------------------------------------------------------------------- -%.d: %.c - $(CC) -M $(CFLAGS) $< -MF $@ -MT $@ -MT $*.o - -%.d: %.cpp - @$(CXX) -M $(CXXFLAGS) $< -MF $@ -MT $@ -MT $*.o - -%.d: %.m - @$(CC) -M $(CFLAGS) $< -MF $@ -MT $@ -MT $*.o - -%.d: %.mm - @$(CXX) -M $(CXXFLAGS) $< -MF $@ -MT $@ -MT $*.o +# Don't error if a .d file is deleted. +$(PREREQS) $(DYLIB_PREREQS): ; #---------------------------------------------------------------------- # Include all of the makefiles for each source file so we don't have # to manually track all of the prerequisites for each source file. #---------------------------------------------------------------------- -sinclude $(PREREQS) -ifneq "$(DYLIB_NAME)" "" - sinclude $(DYLIB_PREREQS) -endif - -# Define a suffix rule for .mm -> .o -.SUFFIXES: .mm .o -.mm.o: - $(CXX) $(CXXFLAGS) -c $< +include $(wildcard $(PREREQS) $(DYLIB_PREREQS)) .PHONY: clean dsym: $(DSYM)
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits