Skip to content

Commit 7f5818f

Browse files
committed
fix macos build and cleanup cmake
1 parent 04e47e9 commit 7f5818f

96 files changed

Lines changed: 417 additions & 377 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ set(LIBCACHESIM_CXX_FLAGS
104104
-Wno-pedantic -Wformat=2 -Wformat-security -Wshadow -Wwrite-strings -Wmissing-include-dirs
105105
)
106106

107+
# maek sure the symbols are exported so that we can use dlsym
108+
set(CMAKE_C_VISIBILITY_PRESET default)
109+
set(CMAKE_VISIBILITY_INLINES_HIDDEN 0)
107110

108111
# Find dependencies
109112
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
@@ -221,7 +224,13 @@ set(libCacheSim_binary_include_dir ${CMAKE_CURRENT_BINARY_DIR}/libCacheSim/inclu
221224

222225
include_directories(${libCacheSim_include_dir})
223226
include_directories(${libCacheSim_binary_include_dir})
224-
set(all_modules cache_lib_c cache_lib_cpp traceReader_lib profiler_lib dataStructure_lib utils_lib traceAnalyzer_lib)
227+
# Restructured to avoid transitive dependency duplicates
228+
# profiler_lib already includes cache_lib_c, cache_lib_cpp, traceReader_lib (which includes utils_lib)
229+
# Only include top-level libraries to avoid duplicates
230+
set(all_modules cache_lib_c cache_lib_cpp traceReader_lib profiler_lib dataStructure_lib utils_lib traceAnalyzer_lib mrcProfiler_lib)
231+
# For linking: use minimal sets to avoid transitive dependency duplicates
232+
set(core_libs cache_lib_c cache_lib_cpp traceReader_lib dataStructure_lib utils_lib)
233+
set(high_level_libs profiler_lib traceAnalyzer_lib)
225234

226235
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libCacheSim/cache)
227236
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libCacheSim/dataStructure)
@@ -250,7 +259,7 @@ endif()
250259
add_library(${PROJECT_NAME} INTERFACE)
251260

252261
# Link all modular libraries into the unified library
253-
target_link_libraries(${PROJECT_NAME} INTERFACE ${all_modules})
262+
target_link_libraries(${PROJECT_NAME} INTERFACE ${high_level_libs})
254263

255264
# Set include directories for the unified library
256265
target_include_directories(${PROJECT_NAME} INTERFACE

libCacheSim/bin/MRC/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ set(mrc_sources_c
1515
)
1616

1717
add_executable(MRC ${mrc_sources_c})
18-
target_link_libraries(MRC ${all_modules} ${dependency_libs})
18+
target_link_libraries(MRC ${core_libs} ${dependency_libs})
1919
install(TARGETS MRC RUNTIME DESTINATION bin)

libCacheSim/bin/MRC/SHARDS.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void generate_shards_mrc(struct PARAM *params, char *path) {
108108
params->reader->init_params.sampler->sampling_ratio = 1.0;
109109
params->reader->sampler->sampling_ratio = 1.0;
110110
uint64_t n_req = get_num_of_req(params->reader);
111-
printf("n_req: %lu\n", n_req);
111+
printf("n_req: %llu\n", (unsigned long long)n_req);
112112
params->reader->init_params.sampler->sampling_ratio = params->rate;
113113
params->reader->sampler->sampling_ratio = params->rate;
114114

libCacheSim/bin/MRC/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ int main(int argc, char **argv) {
5151
(double)return_value[i].n_miss / (double)return_value[i].n_req;
5252
double miss_ratio_byte = (double)return_value[i].n_miss_byte /
5353
(double)return_value[i].n_req_byte;
54-
fprintf(output_file, "%ld,%f, %f\n", cache_size, miss_ratio,
55-
miss_ratio_byte);
54+
fprintf(output_file, "%llu,%f, %f\n", (unsigned long long)cache_size,
55+
miss_ratio, miss_ratio_byte);
5656
}
5757

5858
fclose(output_file);
@@ -66,4 +66,4 @@ int main(int argc, char **argv) {
6666
fprintf(stderr, "Error: unknown algorithm type\n");
6767
return 1;
6868
}
69-
}
69+
}

libCacheSim/bin/MRC/mrc_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,4 @@ void parse_mini_cmd(int argc, char *argv[], struct MINI_arguments *args);
105105

106106
#ifdef __cplusplus
107107
}
108-
#endif
108+
#endif

libCacheSim/bin/cachesim/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ set(cachesim_sources_c
1010
)
1111
add_executable(cachesim ${cachesim_sources_c})
1212
target_include_directories(cachesim PRIVATE ../)
13-
target_link_libraries(cachesim ${all_modules} ${dependency_libs})
14-
target_link_options(cachesim PRIVATE "-Wl,--export-dynamic")
13+
# Link just profiler_lib which now provides all needed libraries transitively
14+
target_link_libraries(cachesim profiler_lib)
15+
# target_link_options(cachesim PRIVATE "-Wl,--export-dynamic") # Not supported on macOS
1516
install(TARGETS cachesim RUNTIME DESTINATION bin)

libCacheSim/bin/cachesim/sim.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void simulate(reader_t *reader, cache_t *cache, int report_interval,
8181

8282
if (!ignore_obj_size) convert_size_to_str(cache->cache_size, size_str);
8383
#pragma GCC diagnostic push
84-
#pragma GCC diagnostic ignored "-Wformat-truncation"
84+
// Removed unknown pragma warning
8585
if (!ignore_obj_size) {
8686
snprintf(output_str, 1024,
8787
"%s %s cache size %8s, %16lu req, miss ratio %.4lf, throughput "
@@ -91,10 +91,11 @@ void simulate(reader_t *reader, cache_t *cache, int report_interval,
9191
(double)req_cnt / 1000000.0 / runtime);
9292
} else {
9393
snprintf(output_str, 1024,
94-
"%s %s cache size %8ld, %16lu req, miss ratio %.4lf, throughput "
94+
"%s %s cache size %8lld, %16lu req, miss ratio %.4lf, throughput "
9595
"%.2lf MQPS\n",
96-
reader->trace_path, detailed_cache_name, cache->cache_size,
97-
(unsigned long)req_cnt, (double)miss_cnt / (double)req_cnt,
96+
reader->trace_path, detailed_cache_name,
97+
(long long)cache->cache_size, (unsigned long)req_cnt,
98+
(double)miss_cnt / (double)req_cnt,
9899
(double)req_cnt / 1000000.0 / runtime);
99100
}
100101

libCacheSim/bin/customized/SOSP23/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ set(flash_sources_cpp
1919
)
2020
add_executable(flash ${flash_sources_cpp})
2121
target_include_directories(flash PRIVATE ../../)
22-
target_link_libraries(flash ${all_modules} utils_lib ${dependency_libs})
22+
target_link_libraries(flash ${core_libs} ${dependency_libs})

libCacheSim/bin/customized/SOSP23/oneHit/cli_parser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,4 @@ void free_arg(struct arguments *args) { close_reader(args->reader); }
162162

163163
#ifdef __cplusplus
164164
}
165-
#endif
165+
#endif

libCacheSim/bin/customized/fast23/fast23.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ void cal_group_metric_over_time(std::string trace_path, std::string ofilepath,
5353
int group_size);
5454
void cal_group_metric_utility_over_time(std::string trace_path,
5555
std::string ofilepath, int group_size);
56-
} // namespace compareGroups
56+
} // namespace compareGroups

0 commit comments

Comments
 (0)