This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add a new rule `add_object`.
ClosedPublic

Authored by sivachandra on Mar 16 2020, 11:43 PM.

Details

Summary

This rule can help add targets to generate special object files like the
crt1.o on linux. Also, it can be used to add specially compiled object
stubs which are to be linked into the entrypoint objects.

Diff Detail

Event Timeline

sivachandra created this revision.Mar 16 2020, 11:43 PM

Could you show how you are using this? I have tried like:

add_object(
  special
  SRC
    special.cpp
  COMPILE_OPTIONS
    -Wframe-larger-than=0
)

add_entrypoint_object(
  entrypoint
  SRCS
    entrypoint.cpp
  HDRS
     entrypoint.h
  DEPENDS
     special
)

Doesn't work, entrypoint doesn't link against special.o

libc/cmake/modules/LLVMLibCRules.cmake
112

Won't add_library compile using CMAKE_CXX_FLAGS?

sivachandra marked an inline comment as done.Mar 17 2020, 9:34 AM

Could you show how you are using this? I have tried like:

add_object(
  special
  SRC
    special.cpp
  COMPILE_OPTIONS
    -Wframe-larger-than=0
)

add_entrypoint_object(
  entrypoint
  SRCS
    entrypoint.cpp
  HDRS
     entrypoint.h
  DEPENDS
     special
)

Doesn't work, entrypoint doesn't link against special.o

I have explained how to use it on the sigaction review page.

libc/cmake/modules/LLVMLibCRules.cmake
112

Yes, but any new compile options you add get added at the end and hence will override (if required) the options earlier in the line.

abrachet accepted this revision.Mar 17 2020, 10:15 AM
This revision is now accepted and ready to land.Mar 17 2020, 10:15 AM
sivachandra marked an inline comment as done.Mar 17 2020, 12:32 PM
sivachandra added inline comments.
libc/cmake/modules/LLVMLibCRules.cmake
134

Looks like object libraries don't give us the flexibility to customize the location and name of the generated object files. I will submit after removing lines 134 to 146 which seem to be doing nothing for an object library.

This revision was automatically updated to reflect the committed changes.