Skip to content

Commit cbc2282

Browse files
committed
Removed trailing slashes from folder paths to avoid kernel building under Windows (MSVS).
1 parent 9f6bf16 commit cbc2282

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

ocl.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,12 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *alg
369369
strcpy(build_data->source_filename, filename);
370370
strcpy(build_data->platform, name);
371371
strcpy(build_data->sgminer_path, sgminer_path);
372-
if (opt_kernel_path && *opt_kernel_path)
372+
if (opt_kernel_path && *opt_kernel_path) {
373373
build_data->kernel_path = opt_kernel_path;
374+
}
375+
else {
376+
build_data->kernel_path = NULL;
377+
}
374378

375379
build_data->work_size = clState->wsize;
376380
build_data->has_bit_align = clState->hasBitAlign;

ocl/build_kernel.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static char *file_contents(const char *filename, int *length)
2020
if (!f) {
2121
/* Then from `pwd`/kernel/ */
2222
strcpy(fullpath, sgminer_path);
23-
strcat(fullpath, "kernel/");
23+
strcat(fullpath, "/kernel/");
2424
strcat(fullpath, filename);
2525
f = fopen(fullpath, "rb");
2626
}
@@ -49,7 +49,7 @@ static char *file_contents(const char *filename, int *length)
4949
void set_base_compiler_options(build_kernel_data *data)
5050
{
5151
char buf[255];
52-
sprintf(data->compiler_options, "-I \"%s\" -I \"%skernel\" -I \".\" -D WORKSIZE=%d",
52+
sprintf(data->compiler_options, "-I \"%s\" -I \"%s\\kernel\" -I \".\" -D WORKSIZE=%d",
5353
data->sgminer_path, data->sgminer_path, (int)data->work_size);
5454
applog(LOG_DEBUG, "Setting worksize to %d", (int)(data->work_size));
5555

@@ -61,7 +61,7 @@ void set_base_compiler_options(build_kernel_data *data)
6161
applog(LOG_DEBUG, "cl_amd_media_ops found, setting BITALIGN");
6262
} else
6363
applog(LOG_DEBUG, "cl_amd_media_ops not found, will not set BITALIGN");
64-
64+
6565
if (data->kernel_path) {
6666
strcat(data->compiler_options, " -I \"");
6767
strcat(data->compiler_options, data->kernel_path);
@@ -126,10 +126,9 @@ cl_program build_opencl_kernel(build_kernel_data *data, const char *filename)
126126
applog(LOG_ERR, "Error %d: Building Program (clBuildProgram)", status);
127127
status = clGetProgramBuildInfo(program, *data->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
128128

129-
char *sz_log = (char *)malloc(log_size + 1);
129+
char *sz_log = (char *)malloc(log_size);
130130
status = clGetProgramBuildInfo(program, *data->device, CL_PROGRAM_BUILD_LOG, log_size, sz_log, NULL);
131-
sz_log[log_size] = '\0';
132-
applog(LOG_ERR, "%s", sz_log);
131+
applogsiz(LOG_ERR, log_size, "%s", sz_log);
133132
free(sz_log);
134133
goto out;
135134
}

sgminer.c

-7
Original file line numberDiff line numberDiff line change
@@ -7913,10 +7913,8 @@ int main(int argc, char *argv[])
79137913
s = strdup(argv[0]);
79147914
strcpy(sgminer_path, dirname(s));
79157915
free(s);
7916-
strcat(sgminer_path, "/");
79177916
#else
79187917
GetCurrentDirectory(PATH_MAX - 1, sgminer_path);
7919-
strcat(sgminer_path, "\\");
79207918
#endif
79217919

79227920
/* Default algorithm specified in algorithm.c ATM */
@@ -8001,11 +7999,6 @@ int main(int argc, char *argv[])
80017999
char *old_path = opt_kernel_path;
80028000
opt_kernel_path = (char *)alloca(PATH_MAX);
80038001
strcpy(opt_kernel_path, old_path);
8004-
#ifdef _MSC_VER
8005-
strcat(opt_kernel_path, "\\");
8006-
#else
8007-
strcat(opt_kernel_path, "/");
8008-
#endif
80098002
}
80108003

80118004

0 commit comments

Comments
 (0)