Skip to content

Windows: fixes#282

Closed
ghost wants to merge 45 commits into
masterfrom
unknown repository
Closed

Windows: fixes#282
ghost wants to merge 45 commits into
masterfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Oct 20, 2017

Copy link
Copy Markdown

Attached are some fixes for the windows functions.

@ghost

ghost commented Oct 20, 2017

Copy link
Copy Markdown
Author

I don't think there's been a single contributor pull request accepted, looking at the history.

@sscalpone Are you going to merge (not now, but eventually) this or was this a waste of time?

@sscalpone

Copy link
Copy Markdown
Member

A few contributor requests have been merged for README.md and CMakefile.txt files. Flang needs to have a CLA for source-file changes. We are working to create this CLA now. We will review on flang-dev list soon.

@ghost

ghost commented Oct 22, 2017

Copy link
Copy Markdown
Author

I should mention that the timing functions don't actually work; I'm not sure what they're for.

@ghost

ghost commented Oct 24, 2017

Copy link
Copy Markdown
Author

You might or might not need _fileno. Not sure what the type of that struct is.

@sscalpone

Copy link
Copy Markdown
Member

We haven't pushed out Windows implementation files to github yet. I'm working on a pull request to get the windows sources into the repo. With hope, they'll start showing up tomorrow (Tuesday) to support your efforts. Do you have changes for flang-compiler/clang too?

@ghost

ghost commented Oct 24, 2017

Copy link
Copy Markdown
Author

No. Changes were not required there. I implemented some of the functions in a "quick" (eg. nonworking) way just to get the compilation going. Then I triaged those functions so that I could come back to them later (#285, #283).

@isuruf Had to fix CMake so that it would call the linker correctly.

I really wish for the CLA so that there's no duplication of work.

@ghost

ghost commented Oct 24, 2017

Copy link
Copy Markdown
Author

Also, would highly recommend merging #284. We spent some time on that.

@ghost ghost left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

A few comments.

Comment thread runtime/flang/buffer.c
__fort_rrecv(ioproc, &off, sizeof(off), 1, __UCHAR);
} else {
off = 0;
fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666);

@ghost ghost Oct 24, 2017

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Should be open(path, O_WRONLY | O_CREAT | O_TRUNC);.

Comment thread runtime/flang/curdir.c
strcpy(host, p);
#else
strcpy(host, "localhost");
#endif

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Should be

#include <Winsock2.h>
char host[128] = "";
gethostname(host, sizeof(host));

@isuruf

isuruf commented Oct 24, 2017

Copy link
Copy Markdown
Collaborator

If anybody is interested, here's the status now.

[ 69%] Linking Fortran shared library ..\..\bin\flang.dll
LINK: command "C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\link.exe /nologo @CMakeFiles\flang_shared.dir\objects1.rsp /out:..\..\bin\flang.dll /implib:..\..\lib\flang.lib /pdb:C:\Users\idf2\flang\build3\bin\flang.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO /DEF:CMakeFiles\flang_shared.dir\exports.def -LIBPATH:C:\Users\idf2\miniconda3\Library\lib ..\..\lib\flangrti.lib libomp.lib /MANIFEST /MANIFESTFILE:..\..\bin\flang.dll.manifest" failed (exit code 1120) with the following output:
etime3f.c.obj : error LNK2005: convert_filetime already defined in dtime3f.c.obj
etime3f.c.obj : error LNK2005: dtime_ already defined in dtime3f.c.obj
cvt.c.obj : warning LNK4197: export 'ecvt' specified multiple times; using first specification
cvt.c.obj : warning LNK4197: export 'fcvt' specified multiple times; using first specification
   Creating library ..\..\lib\flang.lib and object ..\..\lib\flang.exp
amod.c.obj : error LNK2019: unresolved external symbol __fmth_i_amod referenced in function __mth_i_amod
cdcos.c.obj : error LNK2019: unresolved external symbol sincos referenced in function __mth_i_cdcos
cdexp.c.obj : error LNK2001: unresolved external symbol sincos
cexp.c.obj : error LNK2019: unresolved external symbol sincosf referenced in function __mth_i_cexp
dmod.c.obj : error LNK2019: unresolved external symbol __fmth_i_dmod referenced in function __mth_i_dmod
fsync3f.c.obj : error LNK2019: unresolved external symbol fsync referenced in function fsync_
irandm3f.c.obj : error LNK2019: unresolved external symbol srand48 referenced in function irandm_
irandm3f.c.obj : error LNK2019: unresolved external symbol lrand48 referenced in function irandm_
xfer_heap_dum.c.obj : error LNK2019: unresolved external symbol sbrk referenced in function __fort_sbrk
nmlwrite.c.obj : error LNK2001: unresolved external symbol __fortio_binary_mode
rewind.c.obj : error LNK2001: unresolved external symbol __fortio_binary_mode
backspace.c.obj : error LNK2001: unresolved external symbol __fortio_binary_mode
close.c.obj : error LNK2001: unresolved external symbol __fortio_binary_mode
fmtwrite.c.obj : error LNK2001: unresolved external symbol __fortio_binary_mode
ldwrite.c.obj : error LNK2001: unresolved external symbol __fortio_binary_mode
miscsup_com.c.obj : error LNK2019: unresolved external symbol gettimeofday referenced in function fort_dandt
type.c.obj : error LNK2019: unresolved external symbol __get_fort_size_of referenced in function f90_poly_asn
utils.c.obj : error LNK2019: unresolved external symbol ftruncate referenced in function __fortio_rwinit
init.c.obj : error LNK2019: unresolved external symbol __fort_sethand referenced in function __fort_begpar
..\..\bin\flang.dll : fatal error LNK1120: 13 unresolved externals

@ghost

ghost commented Oct 24, 2017

Copy link
Copy Markdown
Author

@isuruf did you add my __fortio_binary_mode?

@ghost

ghost commented Oct 24, 2017

Copy link
Copy Markdown
Author

Also, gettimeofday is at microsoft/vcpkg#1991.

@isuruf

isuruf commented Oct 25, 2017

Copy link
Copy Markdown
Collaborator

@isuruf did you add my __fortio_binary_mode?

No, I didn't. I'll do that once I get some time.

@ghost

ghost commented Oct 25, 2017

Copy link
Copy Markdown
Author

One more interesting bit is that there shouldn't be an ifdef here:

return __fmth_i_amod(f, g);

@ghost

ghost commented Oct 25, 2017

Copy link
Copy Markdown
Author

It should be

float
__mth_i_amod(float f, float g)
{
  return FMODF(f, g);
}

@ghost

ghost commented Oct 25, 2017

Copy link
Copy Markdown
Author

sincos:

extern void sincos(double x, double *sine, double *cosine) {
    sine = sin(x);
    cosine = cos(x);
}

@ghost

ghost commented Oct 25, 2017

Copy link
Copy Markdown
Author

Actually the sbrk implementation is a bit trickier. I've opened emeryberger/Malloc-Implementations#1 to attempt to obtain a legally-compatible implementation in a time-efficient way. I currently don't have time to re-implement a memory allocator.

@isuruf

isuruf commented Oct 25, 2017

Copy link
Copy Markdown
Collaborator

I've pushed some fixes to my branch and the errors now are,

[ 69%] Linking Fortran shared library ..\..\bin\flang.dll
LINK: command "C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\link.exe /nologo @CMakeFiles\flang_shared.dir\objects1.rsp /out:..\..\bin\flang.dll /implib:..\..\lib\flang.lib /pdb:C:\Users\idf2\flang\build3\bin\flang.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO /DEF:CMakeFiles\flang_shared.dir\exports.def -LIBPATH:C:\Users\idf2\miniconda3\Library\lib ..\..\lib\flangrti.lib libomp.lib /MANIFEST /MANIFESTFILE:..\..\bin\flang.dll.manifest" failed (exit code 1120) with the following output:
etime3f.c.obj : error LNK2005: convert_filetime already defined in dtime3f.c.obj
etime3f.c.obj : error LNK2005: dtime_ already defined in dtime3f.c.obj
cvt.c.obj : warning LNK4197: export 'ecvt' specified multiple times; using first specification
cvt.c.obj : warning LNK4197: export 'fcvt' specified multiple times; using first specification
   Creating library ..\..\lib\flang.lib and object ..\..\lib\flang.exp
dmod.c.obj : error LNK2019: unresolved external symbol __fmth_i_dmod referenced in function __mth_i_dmod
fsync3f.c.obj : error LNK2019: unresolved external symbol fsync referenced in function fsync_
irandm3f.c.obj : error LNK2019: unresolved external symbol srand48 referenced in function irandm_
irandm3f.c.obj : error LNK2019: unresolved external symbol lrand48 referenced in function irandm_
xfer_heap_dum.c.obj : error LNK2019: unresolved external symbol sbrk referenced in function __fort_sbrk
type.c.obj : error LNK2019: unresolved external symbol __get_fort_size_of referenced in function f90_poly_asn
utils.c.obj : error LNK2019: unresolved external symbol ftruncate referenced in function __fortio_rwinit
init.c.obj : error LNK2019: unresolved external symbol __fort_sethand referenced in function __fort_begpar
..\..\bin\flang.dll : fatal error LNK1120: 8 unresolved externals

@albertziegenhagel

Copy link
Copy Markdown

FYI: @diorcety has a branch [1] that ported flang to windows in his own fork as well. I don't know how far he got but I think he did very similar changes to yours. Maybe your work can benefit from one another:

[1] https://github.com/diorcety/flang/tree/win32

@ghost

ghost commented Oct 25, 2017

Copy link
Copy Markdown
Author

He doesn't have sbrk either!

@isuruf

isuruf commented Oct 25, 2017

Copy link
Copy Markdown
Collaborator

That branch has almost all of our fixes and some not in this PR.

@ghost

ghost commented Oct 25, 2017

Copy link
Copy Markdown
Author

@albertziegenhagel It would be helpful if you wrote functions for some of those symbols.

@ghost

ghost commented Oct 25, 2017

Copy link
Copy Markdown
Author

Looks like no one responded to his first PR and he gave up. That is sad.

@albertziegenhagel

Copy link
Copy Markdown

I may have time to look into some of the functions this weekend.

It would be interesting to see how mature the windows files that @sscalpone mentioned are. I don't think it makes sense to do all of the work twice in the end.

@ghost

ghost commented Oct 25, 2017

Copy link
Copy Markdown
Author

Switching the branch...

@ghost ghost closed this Oct 25, 2017
@ghost ghost deleted the windows branch October 25, 2017 18:29
@ghost

ghost commented Oct 25, 2017

Copy link
Copy Markdown
Author

Continues in #288.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants