-
-
Notifications
You must be signed in to change notification settings - Fork 304
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
XSim: better Windows support + add xcix IP import #1246
Conversation
Please notice the fact that many people is using SpinalHDL on Windows without MSYS2 environment. So if it is on Windows there might be chance that MSYS2_ROOT is not there at all. |
The only files I changed are related to XSim usage, But I admit that for any Windows user who wants to use XSim, the I kept using MSYS2 shell in this PR because that's what was used previously already. I found some mingw in |
if (isWindows) { | ||
val msys2ShellPath = | ||
sys.env.getOrElse("MSYS2_ROOT", "C:\\msys64") + "\\msys2_shell.cmd" | ||
if (!new File(msys2ShellPath).exists) { |
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.
this part is what I concerned.
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.
indeed I completely missed that this would fail on msys2 shell, thanks for spotting it!
could be changed to msys2Shell
gets :
sh
if sbt run by msys (check withsys.env.get("MSYSTEM")
?)- the full
%MSYS2_ROOT%\\msys2_shell.cmd -defterm -here -no-start -mingw64
if ran by cmd
would that be good enough ?
pretty unsure about checking msys vs cmd with only MSYSTEM
envvar,
thought about checking if sh
exists, but there can be some other sh
in cmd PATH
if (isWindows) { | ||
s"sh -c \'${baseCommand}\'" | ||
s"cmd /c $baseCommand" |
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.
so do you use cmd console by default?
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.
yes, as mentioned in the issue a few times :
my goal was using native cmd console by default to call everything that can be :
vivado.bat
, and its generated compile.bat
and elaborate.bat
:
so whatever if user starts sbt from cmd or from msys shell :
- all
.bat
will be run by cmd - the
g++
command to buildspinal_xsim.dll
is run by msysShell
@@ -111,6 +124,15 @@ class XSimBackend(config: XSimBackendConfig) extends Backend { | |||
throw new Exception(message) | |||
} | |||
} | |||
def doCmdMys2(command: String, cwd: File, message : String) = { | |||
val cmd_msys2 = s""" $msys2Shell -defterm -here -no-start -mingw64 -c "$command" """.trim |
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.
this command would not use env variable in msys if you start it through cmd shell on Windows.
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.
yes, because on windows the build of spinal_xsim.dll
depends only on the VIVADO_HOME
env var to copy locally needed include files.
This behavior was already there before those commits, and I kept it,
as it allows to have this only step which actually doesn't depends on any PATH (cmd or msys) env var.
there are normally 3 ways to use.
|
For the windows cases: aren't they the same in the sense that g++ must always run in the msys environment (since the compiler is installed there), whereas vivado "must" always run in the cmd environment (since there are no environment settings files for bash, only I think from that point it makes sense to call g++ via msys and vivado via cmd. |
you are using method 2. I am currently use the MSYS2 shell to start Vivado, the description in SpinalHDL/SpinalDoc-RTD#230 has been tested without cmd at all. and also with the all-in-one msys2 bundle. A easy and unify method is prefered, because the environment of Windows norrmally a mess while the number of programs increasing. |
- always use cmd to call Vivado related scripts - always using msys's g++ to build XSIIFace dll
@Readon anything else from your side, from my POV we can merge this (I tried it on Linux) |
I still could not run this under msys2 environment. |
What I am using is the portable environment installed by MSYS2-installer. I think in MSYS2 there sould be no assumption that there would be a cmd.exe exist. |
I also tested in the cmd console it still prompt that "Please Setup you MSYS2_ROOT Environment Variable." after I have set it by "set MSYS2_ROOT="xxxxxxx"". I have to define all environment variable in Windows System's advance settings. It might be not good if I just want to run it once, but pollute my whole environment variables. After that, I still get " Generation of vivado script failed" error with backtrace like below. [error] at spinal.sim.XSimBackend.doCmd(XSimBackend.scala:125)
[error] at spinal.sim.XSimBackend.doCmdVivado(XSimBackend.scala:141)
[error] at spinal.sim.XSimBackend.generateScript(XSimBackend.scala:245) |
One more thing, if the xcix is supported after this PR, how about add a minimal test on it? So that we could test this each time the CI runs. |
For any MSYS2 installation, I assumed that we're on Windows, and that the
Windows cmd syntax is very misleading on many things,
Which other env var than the Writing this paragraph above I now realize that the failing at
So yeah I think I cannot properly test running this by sbt from msys2, since my sbt install is in the windows side, |
I admit I just added xcix because I needed it in my project, and just adding it to the IP import list didn't cause any problem from Vivado's pov. Not sure about how to add a proper test for this (still lacking experience in scala testing workflow), |
I suppose it is not a good assumption. I run the TestXSim in a standalone MSYS2 environment, there is no cmd. However, I pushed a PR on your repos, may be that helps. And it can call the
Yes, this might be the problem.
It's weird that it can get VIVADO_HOME when I define it in console but in the system. And fails to get for
If you want you can install the MSYS2-Installer, and define the environment variable in that. It can work either on current upstream code, and on the PR I have pushed on your repo. The only problem remains is that I could not get the Windows starter, by cmd, to work now. |
I think there is no, and the xcix is normally a commercially used one, I am not sure if you can upload it here. |
make the standalone MSYS2 runs.
Sorry for the late response. However, on Windows cmd & MSYS2 mixed environment it still report "UnsatisfiedLinkError", even when I defined VIVADO_HOME and add %VIVADO_HOME%\lib\win64.o to my PATH. |
Sorry for the late response. Thanks for the contribution. |
Follow-up to #1234
Context, Motivation & Description
cmd
native shellspinal_xsim.dll
xcix
import alongxci
IPImpact on code generation
None
Checklist
- [ ] Unit tests were added