Commit a5a4e1c0 authored by John van Groningen's avatar John van Groningen
Browse files

Merge branch '2-64-bit-windows-version' into 'master'

Add a 64-bit Windows version

Closes #2

See merge request !9
parents 617c7d76 6687616f
Pipeline #45906 passed with stage
in 14 seconds
linux:
image: gcc:latest
script:
- make -f Makefile.linux64
artifacts:
paths:
- clm
windows:
image: debian:buster-slim
before_script:
- apt-get update -qq
- apt-get install -yy build-essential mingw-w64
script:
- make CC=i686-w64-mingw32-gcc -f Makefile.windows-x86
artifacts:
paths:
- clm.exe
image: gcc:latest
script:
- make -f Makefile.linux64
artifacts:
paths:
- clm
CC=gcc
CFLAGS=-pedantic -Wall -W
CPPFLAGS=-DGNU_C -D_WINDOWS_ -DI486 -DA_64
clm: clm.o
$(CC) clm.o -o clm
clm.o: clm.c cachingcompiler.h
CC=gcc
CFLAGS=-pedantic -Wall -W
CPPFLAGS=-DGNU_C -D_WINDOWS_ -DI486
CPPFLAGS=-DGNU_C -D_WINDOWS_ -DI486
clm: clm.o
$(CC) clm.o -o clm
......
......@@ -6,7 +6,6 @@ clm is included in all clean distributions. However, if you cannot wait for the
nightly build you can download one of the automatic builds here:
- [linux-64](https://gitlab.science.ru.nl/clean-and-itasks/clm/builds/artifacts/master/file/clm?job=linux)
- [windows-64](https://gitlab.science.ru.nl/clean-and-itasks/clm/builds/artifacts/master/file/clm.exe?job=windows)
### Contributing
......
......@@ -29,7 +29,7 @@
#include <string.h>
#include <ctype.h>
#if defined(I486) || defined (LINUX)
#if defined(LINUX) || (defined(I486) && !defined(_WINDOWS_))
# include <unistd.h>
#endif
......@@ -75,6 +75,7 @@
# include <WinUser.h>
# endif
# else
# define QUOTE_SPAWN_ARGUMENTS
# include <windef.h>
# include <winbase.h>
# include <winGDI.h>
......@@ -89,7 +90,7 @@ extern char *getenv();
#define PATH_NAME_STRING_SIZE PATH_MAX
#define PATH_LIST_STRING_SIZE (PATH_MAX*4)
#else
#define PATH_NAME_STRING_SIZE 256
#define PATH_NAME_STRING_SIZE 260
#define PATH_LIST_STRING_SIZE 1024
#endif
......@@ -469,7 +470,11 @@ static int clean_path_list_max_size;
static char *clean_lib_path,clean_lib_path_copy[PATH_NAME_STRING_SIZE];
#ifdef _WINDOWS_
# ifdef A_64
static char *clean_cocl_file_name="CleanCompiler64.exe";
# else
static char *clean_cocl_file_name="CleanCompiler.exe";
# endif
#else
static char *clean_cocl_file_name="cocl";
#endif
......@@ -659,10 +664,10 @@ int find_clean_system_file (char *file_name,char *extension,char *complete_file_
#ifdef _WINDOWS_
/* Special case for run time system on windows:
The _startup.dcl file is implemented by multiple .o files
(_startup0.o, _startup1.o, _startup2.o)
If _startup0.o is searched for, _startup.dlc
(_startup0.o, _startup1.o, _startup2.o, etc.)
If _startup0.o is searched for, _startup.dcl
*/
if(!strcmp(file_name,"_startup0") || !strcmp(file_name,"_startup1") || !strcmp(file_name,"_startup2")) {
if(!strncmp(file_name,"_startup",8) && isdigit(file_name[8]) && file_name[9]=='\0') {
found = find_file("_startup",".dcl",complete_file_name,first_path,file_time_p);
if(found) {
/* Replace "_startup.dcl" at the end of the file name with the original
......@@ -698,8 +703,10 @@ static void need_file (char *file_name,char *extension,char *complete_file_name)
#ifdef _WINDOWS_
FileTime time;
# ifdef QUOTE_SPAWN_ARGUMENTS
complete_file_name[0]='\"';
++complete_file_name;
# endif
#endif
if (!find_clean_system_file (file_name, extension,complete_file_name,NULL
......@@ -707,13 +714,13 @@ static void need_file (char *file_name,char *extension,char *complete_file_name)
,&time
#endif
)){
#ifdef _WINDOWS_
#ifdef QUOTE_SPAWN_ARGUMENTS
strcat (complete_file_name,"\"");
#endif
fprintf (stderr,"Couldn't find %s%s\n", file_name, extension);
exit (1);
}
#ifdef _WINDOWS_
#ifdef QUOTE_SPAWN_ARGUMENTS
else
strcat (complete_file_name,"\"");
#endif
......@@ -1708,7 +1715,7 @@ static void stop_compiler (void)
}
}
static int call_compiler (char */*unused*/cocl_file_name, char **argv)
static int call_compiler (char * /*unused*/cocl_file_name, char **argv)
{
int r;
char *args;
......@@ -1900,12 +1907,12 @@ static int compile_project_node (P_NODE project_node)
}
strcpy (last_colon,"Clean System Files");
if (access (abc_file_name,F_OK)!=0){
# ifdef _WINDOWS_
if (access (abc_file_name,0)!=0){
#ifdef QUOTE_SPAWN_ARGUMENTS
if (mkdir (abc_file_name)!=0)
# else
#else
if (mkdir (abc_file_name,0777)!=0)
# endif
#endif
error_s ("Could not create directory %s\n",abc_file_name);
}
......@@ -2100,7 +2107,7 @@ static int compile_project_node (P_NODE project_node)
static int generate_code_for_project_node (P_NODE project_node,char *file_name)
{
char *argv[16],**arg;
#ifdef _WINDOWS_
#ifdef QUOTE_SPAWN_ARGUMENTS
char quoted_cg_file_name[PATH_NAME_STRING_SIZE];
#endif
......@@ -2134,13 +2141,21 @@ static int generate_code_for_project_node (P_NODE project_node,char *file_name)
strcpy (cg_file_name,clean_lib_path);
#ifdef _WINDOWS_
# ifdef A_64
strcat (cg_file_name,"\\CodeGenerator64.exe");
# else
strcat (cg_file_name,"\\CodeGenerator.exe");
# endif
# ifdef QUOTE_SPAWN_ARGUMENTS
quoted_cg_file_name[0]='\"';
strcpy (quoted_cg_file_name+1,cg_file_name);
strcat (quoted_cg_file_name+1,"\"");
argv[0]=quoted_cg_file_name;
# else
argv[0]=cg_file_name;
# endif
# ifdef SPAWNVP_AND_WAIT
{
......@@ -2358,7 +2373,7 @@ static int make_project_to_o_files (void)
for_l (project_node,first_project_node,pro_next){
if (project_node->pro_up_to_date && !project_node->pro_ignore_o && !project_node_is_o_up_to_date (project_node)){
#ifdef _WINDOWS_
#ifdef QUOTE_SPAWN_ARGUMENTS
char file_name_s[PATH_NAME_STRING_SIZE],*file_name;
file_name_s[0]='\"';
......@@ -2381,10 +2396,11 @@ static int make_project_to_o_files (void)
file_name[strlen (file_name)-4]='\0';
#ifdef _WINDOWS_
#ifdef QUOTE_SPAWN_ARGUMENTS
strcat (file_name,"\"");
file_name = file_name_s;
#endif
if (!generate_code_for_project_node (project_node,file_name))
return 0;
#if !defined (NO_ASSEMBLE)
......@@ -2466,10 +2482,18 @@ data [] =
#ifdef I486
# ifdef _WINDOWS_
/* header offset 0 */
# ifdef A_64
int_to_2_chars (0x8664)/*machine_type*/,
# else
int_to_2_chars (0x14c)/*machine_type*/,
# endif
int_to_2_chars (3)/*n_sections*/,
int_to_4_chars (817729185)/*time_date_stamp*/,
# ifdef A_64
int_to_4_chars (188)/*symbol_table_pointer*/,
# else
int_to_4_chars (164)/*symbol_table_pointer*/,
# endif
int_to_4_chars (14)/*n_symbols*/,
int_to_2_chars (0)/*optional_header_size*/,
int_to_2_chars (0x0104)/*characteristics*/,
......@@ -2508,105 +2532,170 @@ data [] =
int_to_4_chars (0xc0000080)/*bss_section_flags*/,
/* data section offset 140 */
int_to_4_chars (0)/*heap_size*/,
# ifdef A_64
int_to_4_chars (0),
# endif
int_to_4_chars (0)/*stack_size*/,
# ifdef A_64
int_to_4_chars (0),
# endif
int_to_4_chars (0)/*flags*/,
# ifdef A_64
int_to_4_chars (0),
# endif
int_to_4_chars (0)/*initial_heap_size*/,
# ifdef A_64
int_to_4_chars (0),
# endif
int_to_4_chars (0)/*heap_size_multiple*/,
# ifdef A_64
int_to_4_chars (0),
# endif
int_to_4_chars (0)/*min_write_heap_size*/,
# ifdef A_64
int_to_4_chars (0),
# endif
/* symbol table offset */
/* .file at 164 */
/* .file at 164 / 188 */
'.','f','i','l', 'e','\0','\0','\0',
int_to_4_chars (0)/*file_value*/,
int_to_2_chars (65534)/*file_section_n(IMAGE_SYM_DEBUG)*/,
int_to_2_chars (0)/*file_type*/,
(char) 103/*file_storage_class(IMAGE_SYM_CLASS_FILE)*/,
(char) 1/*file_n_aux_sections*/,
/* fake (aux to .file) at 182 */
/* fake (aux to .file) at 182 / 206 */
'f','a','k','e','\0','\0','\0','\0',
int_to_4_chars (0)/*file_aux_value*/,
int_to_2_chars (0)/*file_aux_section_n(IMAGE_SYM_UNDEFINED)*/,
int_to_2_chars (0)/*file_aux_type*/,
(char) 0/*file_aux_storage_class(IMAGE_SYM_CLASS_NULL)*/,
(char) 0 /*file_aux_n_aux_sections*/,
/* .text at 200 */
/* .text at 200 / 224 */
'.','t','e','x','t','\0','\0','\0',
int_to_4_chars (0)/*text_value*/,
int_to_2_chars (1)/*text_section_n*/,
int_to_2_chars (0)/*text_type*/,
(char) 3/*text_storage_class(IMAGE_SYM_CLASS_STATIC)*/,
(char) 1/*text_n_aux_sections*/,
/* null to .text at 214 */
/* null to .text at 214 / 238 */
int_to_4_chars (0)/*text_raw_data_size*/,
'\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0'/*null_aux_entry*/,
/* .data at 236 */
/* .data at 236 / 260 */
'.','d','a','t','a','\0','\0','\0',
int_to_4_chars (0)/*data_value*/,
int_to_2_chars (2)/*data_section_n*/,
int_to_2_chars (0)/*data_type*/,
(char) 3/*data_storage_class(IMAGE_SYM_CLASS_STATIC)*/,
(char) 1/*data_n_aux_sections*/,
/* null to .data at 254 */
/* null to .data at 254 / 278 */
# ifdef A_64
int_to_4_chars (48)/*data_raw_data_size*/,
# else
int_to_4_chars (24)/*data_raw_data_size*/,
# endif
'\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0'/*null_aux_entry*/,
/* .bss at 272 */
/* .bss at 272 / 296 */
'.','b','s','s','\0','\0','\0','\0',
int_to_4_chars (20)/*bss_value*/,
int_to_2_chars (3)/*bss_section_n*/,
int_to_2_chars (0)/*bss_type*/,
(char) 3/*bss_storage_class(IMAGE_SYM_CLASS_STATIC)*/,
(char) 1/*bss_n_aux_sections*/,
/* null to .bss at 290 */
/* null to .bss at 290 / 314 */
int_to_4_chars (0)/*bss_raw_data_size*/,
'\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0'/*null_aux_entry*/,
/* _heap_size at 306 */
/* _heap_size at 306 / 330 */
int_to_4_chars (0), int_to_4_chars (4)/*heap_size_offset*/,
int_to_4_chars (0)/*heap_size_value*/,
int_to_2_chars (2)/*heap_size_section_n*/,
int_to_2_chars (0)/*heap_size_type*/,
(char) 2/*heap_size_class(IMAGE_SYM_CLASS_EXTERNAL)*/,
(char) 0/*heap_size_n_aux_sections*/,
/* _ab_stack_size at 326 */
int_to_4_chars (0), int_to_4_chars (15)/*ab_stack_size_offset*/,
/* _ab_stack_size at 326 / 360 */
int_to_4_chars (0), int_to_4_chars (14)/*ab_stack_size_offset*/,
# ifdef A_64
int_to_4_chars (8)/*ab_stack_size_value*/,
# else
int_to_4_chars (4)/*ab_stack_size_value*/,
# endif
int_to_2_chars (2)/*ab_stack_size_section_n*/,
int_to_2_chars (0)/*ab_stack_size_type*/,
(char) 2/*ab_stack_size_class(IMAGE_SYM_CLASS_EXTERNAL)*/,
(char) 0/*ab_stack_size_n_aux_sections*/,
/* _flags at 344 */
'_','f','l','a','g','s','\0','\0',
/* _flags at 344 / 368 */
# ifndef A_64
'_',
# endif
'f','l','a','g','s','\0','\0',
# ifdef A_64
'\0',
# endif
# ifdef A_64
int_to_4_chars (16)/*flags_value*/,
# else
int_to_4_chars (8)/*flags_value*/,
# endif
int_to_2_chars (2)/*flags_section_n*/,
int_to_2_chars (0)/*flags_type*/,
(char) 2/*flags_class(IMAGE_SYM_CLASS_EXTERNAL)*/,
(char) 0/*flags_n_aux_sections*/,
/* _initial_heap_size at 362 */
int_to_4_chars (0), int_to_4_chars (30)/*initial_heap_size_offset*/,
/* _initial_heap_size at 362 / 386 */
int_to_4_chars (0), int_to_4_chars (28)/*initial_heap_size_offset*/,
# ifdef A_64
int_to_4_chars (24)/*initial_heap_size_value*/,
# else
int_to_4_chars (12)/*initial_heap_size_value*/,
# endif
int_to_2_chars (2)/*initial_heap_size_section_n*/,
int_to_2_chars (0)/*initial_heap_size_type*/,
(char) 2/*initial_heap_size_class(IMAGE_SYM_CLASS_EXTERNAL)*/,
(char) 0/*initial_heap_size_n_aux_sections*/,
/* _heap_size_multiple at 378 */
int_to_4_chars (0), int_to_4_chars (49)/*heap_size_multiple_offset*/,
/* _heap_size_multiple at 378 / 402 */
int_to_4_chars (0), int_to_4_chars (46)/*heap_size_multiple_offset*/,
# ifdef A_64
int_to_4_chars (32)/*heap_size_multiple_value*/,
# else
int_to_4_chars (16)/*heap_size_multiple_value*/,
# endif
int_to_2_chars (2)/*heap_size_multiple_section_n*/,
int_to_2_chars (0)/*heap_size_multiple_type*/,
(char) 2/*heap_size_multiple_class(IMAGE_SYM_CLASS_EXTERNAL)*/,
(char) 0/*heap_size_multiple_n_aux_sections*/,
/* _min_write_heap_size at 396 */
int_to_4_chars (0), int_to_4_chars(69)/*min_write_heap_size_offset*/,
/* _min_write_heap_size at 396 / 420 */
int_to_4_chars (0), int_to_4_chars(65)/*min_write_heap_size_offset*/,
# ifdef A_64
int_to_4_chars (40)/*min_write_heap_size_value*/,
# else
int_to_4_chars (20)/*min_write_heap_size_value*/,
# endif
int_to_2_chars (2)/*min_write_heap_size_section_n*/,
int_to_2_chars (0)/*min_write_heap_size_type*/,
(char) 2/*min_write_heap_size_class(IMAGE_SYM_CLASS_EXTERNAL)*/,
(char) 0/*min_write_heap_size_n_aux_sections*/,
/* string table at 414 */
/* string table at 414 / 438 */
# ifdef A_64
int_to_4_chars (81/*size string_table*/ + 4),
# else
int_to_4_chars (86/*size string_table*/ + 4),
'_','h','e','a','p','_','s','i','z','e','\0',
'_','a','b','_','s','t','a','c','k','_','s','i','z','e','\0',
'_','i','n','i','t','i','a','l','_','h','e','a','p','_','s','i','z','e','\0',
'_','h','e','a','p','_','s','i','z','e','_','m','u','l','t','i','p','l','e','\0',
'_','m','i','n','_','w','r','i','t','e','_','h','e','a','p','_','s','i','z','e','\0'
'_',
# endif
'h','e','a','p','_','s','i','z','e','\0',
# ifndef A_64
'_',
# endif
'a','b','_','s','t','a','c','k','_','s','i','z','e','\0',
# ifndef A_64
'_',
# endif
'i','n','i','t','i','a','l','_','h','e','a','p','_','s','i','z','e','\0',
# ifndef A_64
'_',
# endif
'h','e','a','p','_','s','i','z','e','_','m','u','l','t','i','p','l','e','\0',
# ifndef A_64
'_',
# endif
'm','i','n','_','w','r','i','t','e','_','h','e','a','p','_','s','i','z','e','\0'
# else
# ifdef OMF
0x0b000d80,0x6974706f,0x2e736e6f,0xf36a626f
......@@ -3044,12 +3133,21 @@ int create_options_file (char **options_file_name_p)
data_size=sizeof (data);
#else
# ifdef _WINDOWS_
# ifdef A_64
((size_t*)&data[140])[0]=heap_size;
((size_t*)&data[140])[1]=ab_stack_size;
((size_t*)&data[140])[2]=flags;
((size_t*)&data[140])[3]=initial_heap_size;
((size_t*)&data[140])[4]=heap_size_multiple;
((size_t*)&data[140])[5]=0/*min_write_heap_size*/;
# else
((int*)&data[140])[0]=heap_size;
((int*)&data[140])[1]=ab_stack_size;
((int*)&data[140])[2]=flags;
((int*)&data[140])[3]=initial_heap_size;
((int*)&data[140])[4]=heap_size_multiple;
((int*)&data[140])[5]=0/*min_write_heap_size*/;
# endif
data_size=sizeof (data);
# else
# ifdef MACH_O64
......@@ -3227,6 +3325,9 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
char startup0_file_name[PATH_NAME_STRING_SIZE];
# endif
char startup1_file_name[PATH_NAME_STRING_SIZE],startup2_file_name[PATH_NAME_STRING_SIZE];
# ifdef A_64
char startup3_file_name[PATH_NAME_STRING_SIZE],startup4_file_name[PATH_NAME_STRING_SIZE];
# endif
#else
char start_up_file_name[PATH_NAME_STRING_SIZE];
#endif
......@@ -3305,6 +3406,14 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
need_file ("_startup2",OBJECT_FILE_EXTENSION,startup2_file_name);
*arg++=startup2_file_name;
# ifdef A_64
need_file ("_startup3",OBJECT_FILE_EXTENSION,startup3_file_name);
*arg++=startup3_file_name;
need_file ("_startup4",OBJECT_FILE_EXTENSION,startup4_file_name);
*arg++=startup4_file_name;
# endif
# else
if ((clean_options & NO_TIME_PROFILE_MASK)!=0){
......@@ -3379,7 +3488,7 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
# ifdef _WINDOWS_
strcpy (linker_file_name_,clean_lib_path);
strcat (linker_file_name_,"/StaticLinker.exe");
strcat (linker_file_name_,DIRECTORY_SEPARATOR_STRING "StaticLinker.exe");
# ifdef SPAWNVP_AND_WAIT
argv[0]=linker_file_name_;
......@@ -3456,7 +3565,7 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
# endif
#endif
#if defined (USE_CLEANLINKER)
#if defined (USE_CLEANLINKER) && !defined (_WINDOWS_)
*arg++="-con";
#endif
......@@ -3543,6 +3652,14 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
need_file ("_startup2",OBJECT_FILE_EXTENSION,startup2_file_name);
*arg++=startup2_file_name;
# ifdef A_64
need_file ("_startup3",OBJECT_FILE_EXTENSION,startup3_file_name);
*arg++=startup3_file_name;
need_file ("_startup4",OBJECT_FILE_EXTENSION,startup4_file_name);
*arg++=startup4_file_name;
# endif
#else
if ((clean_options & NO_TIME_PROFILE_MASK)!=0)
need_file ("_startup",OBJECT_FILE_EXTENSION,start_up_file_name);
......@@ -3574,8 +3691,8 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
{
error_s ("Can't find %s.o",project_node->pro_fname);
}
#ifdef _WINDOWS_
#ifdef QUOTE_SPAWN_ARGUMENTS
file_name=memory_allocate (strlen (o_file_name)+3);
file_name[0]='\"';
......@@ -3640,21 +3757,33 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
*arg++="-lc";
# endif
# if defined (USE_CLEANLINKER)
# ifdef QUOTE_SPAWN_ARGUMENTS
strcpy (kernel32_file_name,"\"-l");
strcpy (kernel32_file_name+3,system_file_name+1);
replace_file_name_in_path (kernel32_file_name+3,"kernel_library","");
strcat (kernel32_file_name+3,"\"");
*arg++ = kernel32_file_name;
strcpy (user32_file_name,"\"-l");
strcpy (user32_file_name+3,system_file_name+1);
replace_file_name_in_path (user32_file_name+3,"user_library","");
strcat (user32_file_name+3,"\"");
*arg++ = user32_file_name;
strcpy (gdi32_file_name,"\"-l");
strcpy (gdi32_file_name+3,system_file_name+1);
replace_file_name_in_path (gdi32_file_name+3,"gdi_library","");
strcat (gdi32_file_name+3,"\"");
*arg++ = gdi32_file_name;
# else
strcpy (kernel32_file_name,"-l");
strcpy (kernel32_file_name+2,system_file_name);
replace_file_name_in_path (kernel32_file_name+2,"kernel_library","");
*arg++ = kernel32_file_name;
strcpy (user32_file_name,"-l");
strcpy (user32_file_name+2,system_file_name);
replace_file_name_in_path (user32_file_name+2,"user_library","");
*arg++ = user32_file_name;
strcpy (gdi32_file_name,"-l");
strcpy (gdi32_file_name+2,system_file_name);
replace_file_name_in_path (gdi32_file_name+2,"gdi_library","");
*arg++ = gdi32_file_name;
# endif
# else
*arg++="-lkernel32";
# endif
......@@ -4062,7 +4191,11 @@ void init_directories_from_environment()
#ifdef _WINDOWS_
/* CLEANLIB */
strncpy(clean_lib_directory, clean_home, sizeof(clean_lib_directory));
# ifdef A_64
strncat(clean_lib_directory,"\\Tools\\Clean System 64",sizeof(clean_lib_directory) - strlen(clean_lib_directory));
# else
strncat(clean_lib_directory,"\\Tools\\Clean System",sizeof(clean_lib_directory) - strlen(clean_lib_directory));
# endif
/* CLEANPATH */
strncpy(clean_directory_list, clean_home, sizeof(clean_directory_list));
strncat(clean_directory_list,"\\Libraries\\StdEnv",sizeof(clean_directory_list) - strlen(clean_directory_list));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment