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

Linking with MSVC toolchain #75

Open
wants to merge 4 commits into
base: release_60
Choose a base branch
from

Conversation

isuruf
Copy link

@isuruf isuruf commented May 24, 2019

No description provided.

@isuruf
Copy link
Author

isuruf commented May 24, 2019

This is a rebased PR of flang-compiler/clang#37 by @albertziegenhagel

@isuruf
Copy link
Author

isuruf commented May 30, 2019

This is not enough for building Fortran projects using cmake.

In UNIX, cmake would compile a test file and inspect the executable to get the fortran runtime libraries to link to.

In Windows, this is more complicated and clang would embed the linking options in the object files. This is done by adding llvm.linker.options

You can see this by doing,
clang-cl empty.c -c -Xclang -emit-llvm && cat empty.obj which gives me,

; ModuleID = 'empty.c'
source_filename = "empty.c"
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc19.11.0"

; Function Attrs: noinline nounwind optnone sspstrong uwtable
define i32 @main() #0 {
entry:
  %retval = alloca i32, align 4
  store i32 0, i32* %retval, align 4
  ret i32 1
}

attributes #0 = { noinline nounwind optnone sspstrong uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }

!llvm.linker.options = !{!0, !1}
!llvm.module.flags = !{!2, !3}
!llvm.ident = !{!4}

!0 = !{!"/DEFAULTLIB:libcmt.lib"}
!1 = !{!"/DEFAULTLIB:oldnames.lib"}
!2 = !{i32 1, !"wchar_size", i32 2}
!3 = !{i32 7, !"PIC Level", i32 2}
!4 = !{!"clang version 6.0.1 "}

How would you want to do this? In an old PR, what I did was pass them to flang2 like -linker /DEFAULTLIB:libcmt.lib -linker /DEFAULTLIB:oldnames.lib. Is this acceptable?

@isuruf
Copy link
Author

isuruf commented May 30, 2019

See also the discussion at https://gitlab.kitware.com/cmake/cmake/issues/17384#note_337478

@isuruf
Copy link
Author

isuruf commented Jun 1, 2019

Depends on flang-compiler/flang#729

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.

1 participant