Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow override of prefix-map build flag #3228

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .buildkite/lib/generate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function generate(platform::Platform)

echo "--- Build"
make --output-sync -j\$\${JULIA_CPU_THREADS:?}
bin/rr --log all:info bin/simple

echo "--- Test"
mkdir -p Testing/Temporary
Expand Down
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ configure_file(
${CMAKE_BINARY_DIR}/git_revision.h
)

# Custom flags that we'll put in front to allow override from ENV
set(PREFIX_FLAGS_COMMON "")
set(FLAGS_COMMON "-D__USE_LARGEFILE64 -pthread")
set(supports32bit true)
set(x86ish false)
Expand All @@ -71,18 +73,18 @@ configure_file(src/preload/rr_page.ld.in src/preload/rr_page.ld @ONLY)
include(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG("-fmacro-prefix-map=foo=bar" SUPPORTS_MACRO_PREFIX_MAP)
if (SUPPORTS_MACRO_PREFIX_MAP)
set(FLAGS_COMMON "${FLAGS_COMMON} -fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=")
set(PREFIX_FLAGS_COMMON "${PREFIX_FLAGS_COMMON} -fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this supposed to be used? In clang at least, fmacro-prefix-map is a hash table, with later entries overriding earlier ones. Doesn't that moot the usefulness of this option?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by "usefulness of this option"? The point is that distribution should be able to override this. Without any flags passed in, this should behave exactly the same without this PR and as useful as it was.

It does seem that clang and gcc handles this differently. For GCC, it seems that any later flags override earlier ones but for clang, later, less-specific ones does not override earlier flags. To allow distro override to work correctly, it seems that I would need to just disable this if a similar flag is passed in.

endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS_COMMON} -Wstrict-prototypes -std=gnu11")
set(CMAKE_C_FLAGS "${PREFIX_FLAGS_COMMON} ${CMAKE_C_FLAGS} ${FLAGS_COMMON} -Wstrict-prototypes -std=gnu11")
# Define __STDC_LIMIT_MACROS so |#include <stdint.h>| works as expected.
# Define __STDC_FORMAT_MACROS so |#include <inttypes.h>| works as expected.
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++14" SUPPORTS_CXX14)
if (SUPPORTS_CXX14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS_COMMON} -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -std=c++14")
set(CMAKE_CXX_FLAGS "${PREFIX_FLAGS_COMMON} ${CMAKE_CXX_FLAGS} ${FLAGS_COMMON} -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -std=c++14")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS_COMMON} -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -std=c++11")
set(CMAKE_CXX_FLAGS "${PREFIX_FLAGS_COMMON} ${CMAKE_CXX_FLAGS} ${FLAGS_COMMON} -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -std=c++11")
endif()

# We support three build types:
Expand Down