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

[RFC] Refactor work with opencl-c.h resource file #68

Open
wants to merge 1 commit into
base: ocl-open-80
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
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ include(TableGen)

find_package(Git REQUIRED)

if (NOT WIN32)
add_subdirectory( linux_linker )
endif()
add_subdirectory( linux_linker )

if (CMAKE_SIZEOF_VOID_P EQUAL 4)
set(ADDR 32)
Expand Down Expand Up @@ -127,7 +125,6 @@ set(TARGET_INCLUDE_FILES
set(TARGET_SOURCE_FILES
common_clang.cpp
options.cpp
pch_mgr.cpp
options_compile.cpp
)

Expand Down
13 changes: 4 additions & 9 deletions cl_headers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ add_custom_target (
opencl-c.h
)


function(pack_to_obj SRC DST TAG)
add_custom_command (
OUTPUT ${DST}
Expand All @@ -35,14 +34,10 @@ function(pack_to_obj SRC DST TAG)
)
endfunction(pack_to_obj)

if(WIN32)
list(APPEND CL_HEADERS_SRC OpenCL.rc)
else()
pack_to_obj(opencl-c.h opencl-c.h.cpp "PCM_OPENCL_C_H")
list(APPEND CL_HEADERS_SRC
opencl-c.h.cpp
)
endif()
pack_to_obj(opencl-c.h opencl-c.h.cpp "PCM_OPENCL_C_H")
list(APPEND CL_HEADERS_SRC
opencl-c.h.cpp
)

add_library(${CL_HEADERS_LIB} OBJECT
${CL_HEADERS_SRC}
Expand Down
14 changes: 0 additions & 14 deletions cl_headers/OpenCL.rc

This file was deleted.

24 changes: 0 additions & 24 deletions cl_headers/resource.h

This file was deleted.

24 changes: 4 additions & 20 deletions common_clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Copyright (c) Intel Corporation (2009-2017).

#include "common_clang.h"
#include "pch_mgr.h"
#include "cl_headers/resource.h"
#include "binary_result.h"
#include "options.h"

Expand Down Expand Up @@ -111,26 +110,11 @@ void CommonClangInitialize() {
}
}

static bool GetHeaders(std::vector<Resource> &Result) {
struct {const char *ID; const char *Name;} Headers[] = {
{OPENCL_C_H, "opencl-c.h"},
};

Result.clear();
Result.reserve(sizeof(Headers) / sizeof(*Headers));

ResourceManager &RM = ResourceManager::instance();

for (auto Header:Headers) {
Resource R = RM.get_resource(Header.Name, Header.ID, "PCM", true);
if (!R) {
assert(0 && "Resource not found");
return false;
}

Result.push_back(R);
}
extern const char PCM_OPENCL_C_H[];
extern unsigned int PCM_OPENCL_C_H_size;

static bool GetHeaders(std::vector<Resource> &Result) {
Result.push_back(Resource(PCM_OPENCL_C_H, PCM_OPENCL_C_H_size, "opencl-c.h"));
return true;
}

Expand Down
1 change: 0 additions & 1 deletion common_clang.map
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ global:
Compile;
Link;
GetKernelArgInfo;
PCM_OPENCL_C_H*;
};
local: *;
};
8 changes: 4 additions & 4 deletions linux_linker/linux_resource_linker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int main(int argc, char **argv)

if (!argv[1] || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help") || !argv[2] || !argv[3])
{
printf("Usage: bif_linker [input file] [output file] [symbol base name]\n");
printf("Usage: %s [input file] [output file] [symbol base name]\n", argv[0]);
return 0;
}

Expand All @@ -44,8 +44,8 @@ int main(int argc, char **argv)
return 1;
}

fprintf(output, "// This file is auto generated by bo_linker, DO NOT EDIT\n\n");
fprintf(output, "unsigned char __attribute__((visibility(\"default\"))) %s[] =\n{\n ", argv[3]);
fprintf(output, "// This file is auto generated by %s, DO NOT EDIT\n\n", argv[0]);
fprintf(output, "extern const char %s[] =\n{\n ", argv[3]);

int count = 0;
int is_eol;
Expand All @@ -58,7 +58,7 @@ int main(int argc, char **argv)
}
fprintf(output, "0x00\n};\n\n");

fprintf(output, "unsigned int __attribute__((visibility(\"default\"))) %s_size = %d;\n\n", argv[3], count);
fprintf(output, "unsigned int %s_size = %d;\n\n", argv[3], count);
fclose(input);
fclose(output);

Expand Down
Loading