Skip to content

Commit

Permalink
Simplify PIC argument
Browse files Browse the repository at this point in the history
Summary: Previously we'd pass `pic = False` to `_compile_index_store` which would immediately return. Instead, just don't call `_compile_index_store`

Reviewed By: milend

Differential Revision: D68237148

fbshipit-source-id: 2702888b30a3a3babb807572e762c0a63223dc9b
  • Loading branch information
Wilfred authored and facebook-github-bot committed Jan 23, 2025
1 parent ca7853e commit ac76dd7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 1 addition & 5 deletions prelude/apple/apple_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,14 @@ def apple_library_impl(ctx: AnalysisContext) -> [Promise, list[Provider]]:
else:
return get_apple_library_providers([])

def _compile_index_store(ctx: AnalysisContext, src_compile_cmd: CxxSrcCompileCommand, toolchain: CxxToolchainInfo, compile_cmd: cmd_args, pic: bool) -> Artifact | None:
def _compile_index_store(ctx: AnalysisContext, src_compile_cmd: CxxSrcCompileCommand, toolchain: CxxToolchainInfo, compile_cmd: cmd_args) -> Artifact | None:
identifier = src_compile_cmd.src.short_path
if src_compile_cmd.index != None:
# Add a unique postfix if we have duplicate source files with different flags
identifier = identifier + "_" + str(src_compile_cmd.index)
filename_base = identifier
identifier += " (index_store)"

# We generate the index only for pic compilations
if not pic:
return None

if src_compile_cmd.src.extension in AsmExtensions.values():
return None

Expand Down
10 changes: 7 additions & 3 deletions prelude/cxx/compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@ def create_compile_cmds(
comp_db_compile_cmds = src_compile_cmds + hdr_compile_cmds,
)

def _compile_index_store(ctx: AnalysisContext, src_compile_cmd: CxxSrcCompileCommand, toolchain: CxxToolchainInfo, compile_cmd: cmd_args, pic: bool) -> Artifact | None:
def _compile_index_store(ctx: AnalysisContext, src_compile_cmd: CxxSrcCompileCommand, toolchain: CxxToolchainInfo, compile_cmd: cmd_args) -> Artifact | None:
if src_compile_cmd.index_store_factory:
return src_compile_cmd.index_store_factory(ctx, src_compile_cmd, toolchain, compile_cmd, pic)
return src_compile_cmd.index_store_factory(ctx, src_compile_cmd, toolchain, compile_cmd)
return None

COMMON_PREPROCESSOR_OUTPUT_ARGS = cmd_args("-E", "-dD")
Expand Down Expand Up @@ -554,7 +554,11 @@ def _compile_single_cxx(
src_compile_cmd = src_compile_cmd,
pic = pic,
)
index_store = _compile_index_store(ctx, src_compile_cmd, toolchain, compile_index_store_cmd, pic)

index_store = None

if pic:
index_store = _compile_index_store(ctx, src_compile_cmd, toolchain, compile_index_store_cmd)

# Generate asm for compiler which accept `-S` (TODO: support others)
if compiler_type in ["clang", "gcc"]:
Expand Down

0 comments on commit ac76dd7

Please sign in to comment.