-
Notifications
You must be signed in to change notification settings - Fork 68
stdlib Artifact Uploads for Windows #1566
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
base: master
Are you sure you want to change the base?
Conversation
|
Looks like this would work, i started the workflow but i currently don't have access to a windows pc to check the artifact on, so this will have to wait until after new year unless @mhasel , @volsa or @Angus-Bethke-Bachmann are available to test it this week. |
ghaith
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized the artifact might be missing some parts of the standard lib because of hwo it gets compiled, you probably need to test this.
| run: cargo test integration -- --nocapture --test-threads=1 | ||
|
|
||
| - name: Release Build | ||
| run: cargo build --release --workspace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm suspecting the build might not work because part of the std lib is written in ST, which means you will also need to compile the st part of the lib and link the dlls together. Check the package command in scripts/build.sh to see how we do this on linux
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I compiled the library from source and simple symbols such as SQRT can be found but not complex ones, such as REAL_TO_DINT.
The lib/stdlib/build.rs script appears to compile the structured text and link it to the rust part. Why does this require build.sh? From what I understand from the source code, the shell script will copy all the structured text files into the output directory's include folder, before invoking clang.
PS C:\Users\sjsui\Desktop\workshop\stickle> plc ./examples/stdlib_usage.st --linker=cc --target=x86_64-windows-msvc -L C:\Users\sjsui\AppData\Local\rustycompiler -l iec61131std --shared -o ./compiled/libstdlib_usage.dll
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\sjsui\AppData\Local\Temp\.tmpaK5vlz\x86_64-windows-msvc\x86_64-windows-msvc\Users\sjsui\Desktop\workshop\stickle\examples\stdlib_usage.st.o:stdlib_usage.st:(.text+0x17): undefined reference to `REAL_TO_DINT'
collect2.exe: error: ld returned 1 exit status
An error occurred during linking: An error occured during linking.
Hint: You can use `plc explain <ErrorCode>` for more information
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason the build script does not end up linking in the ST code as expected.
This only is a problem on the shared library.
Which is why we call the package std which calls the linker again here :
Line 281 in 50825be
| create_shared_library "$cc" "$lib_dir" "$val" |
The function called simply converts the static library with the correct symbols into a shared library, the key command here is -Wl,whole-archive for the standard lib. https://github.com/PLC-lang/rusty/blob/50825be581ec3457208582ab95e8b932a0a66c45/scripts/build.sh#L212C10-L212C23
This comment has more context
Line 40 in 50825be
| //We can link against the st lib gernerated, but this will only be reflected in static libs. |
it might be working by now it might be worth a try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rust-lang/rust#99429 it would seem support for this has been added. I'll try to see if the linux build behaves as expected in the comming days and we then we probably won't need the script for that anymore
|
With DLL generation put to the side for a moment, I've found that static linking with the generated LIB displays a number of errors on Windows. I used the |
|
@ghaith I compiled My next problem is that usage of clang isn't exporting an entrypoint symbol into the header of the DLL. When I use mingw it succeeds but mingw is incompatible with |
|
I got exported functions with clang by attaching an Here's the working example if anyone wants to try windows development.
|

Based on a previous discussion regarding Windows development, I was able to compile the Rusty project natively on windows by using mingw as the implementation of the CC linker.
To progress the experience of our Windows users further, I've exposed
stdlibas an artifact in the Windows build pipeline. This will allow them to quickly link with the Standard Library, in feature parity with the Linux Pipeline.@ghaith Hello. How do I request a review?