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

Windows: fixes #282

Closed
wants to merge 45 commits into from
Closed

Windows: fixes #282

wants to merge 45 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 20, 2017

Attached are some fixes for the windows functions.

@ghost
Copy link
Author

ghost commented Oct 20, 2017

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
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
Copy link
Author

ghost commented Oct 22, 2017

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

@ghost
Copy link
Author

ghost commented Oct 24, 2017

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

@sscalpone
Copy link
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
Copy link
Author

ghost commented Oct 24, 2017

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
Copy link
Author

ghost commented Oct 24, 2017

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

Copy link
Author

@ghost ghost left a comment

Choose a reason for hiding this comment

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

A few comments.

@@ -72,7 +72,7 @@ __fort_zopen(char *path)
__fort_rrecv(ioproc, &off, sizeof(off), 1, __UCHAR);
} else {
off = 0;
fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
Copy link
Author

@ghost ghost Oct 24, 2017

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);.

@@ -113,4 +116,7 @@ void __fort_gethostname(host) char *host;
p = un.nodename;
}
strcpy(host, p);
#else
strcpy(host, "localhost");
#endif
Copy link
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
Copy link
Collaborator

isuruf commented Oct 24, 2017

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
Copy link
Author

ghost commented Oct 24, 2017

@isuruf did you add my __fortio_binary_mode?

@ghost
Copy link
Author

ghost commented Oct 24, 2017

Also, gettimeofday is at microsoft/vcpkg#1991.

@isuruf
Copy link
Collaborator

isuruf commented Oct 25, 2017

@isuruf did you add my __fortio_binary_mode?

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

@ghost
Copy link
Author

ghost commented Oct 25, 2017

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

return __fmth_i_amod(f, g);

@ghost
Copy link
Author

ghost commented Oct 25, 2017

It should be

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

@ghost
Copy link
Author

ghost commented Oct 25, 2017

sincos:

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

@ghost
Copy link
Author

ghost commented Oct 25, 2017

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
Copy link
Collaborator

isuruf commented Oct 25, 2017

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

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
Copy link
Author

ghost commented Oct 25, 2017

He doesn't have sbrk either!

@isuruf
Copy link
Collaborator

isuruf commented Oct 25, 2017

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

@ghost
Copy link
Author

ghost commented Oct 25, 2017

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

@ghost
Copy link
Author

ghost commented Oct 25, 2017

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

@albertziegenhagel
Copy link

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
Copy link
Author

ghost commented Oct 25, 2017

Switching the branch...

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

ghost commented Oct 25, 2017

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