Giter Club home page Giter Club logo

zig-sdk's People

Contributors

alexrp avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

rofrol

zig-sdk's Issues

Set rpath and soname to sensible default(s)

We definitely need to pass -rpath '$ORIGIN'. We might also need to consider -rpath '$ORIGIN/runtimes/<rid>/native'.

For these to actually work properly, we also need to pass -soname libfoo.so for shared libraries.

Investigate whether we need to do anything special for `dotnet publish` to work

It seems to be fine:

$ dotnet publish
Microsoft (R) Build Engine version 17.0.0-preview-21302-02+018bed83d for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  clib -> C:\Users\alex\source\repos\zig-msbuild-sdk\src\samples\clib\bin\Debug\win-x64\clib.dll
  clib -> C:\Users\alex\source\repos\zig-msbuild-sdk\src\samples\clib\bin\Debug\win-x64\publish\

~/source/repos/zig-msbuild-sdk/src/samples/clib  master
$ ls bin/Debug/win-x64/publish/
clib.dll  clib.pdb

But there may be edge cases we aren't covering.

This might tie into:

Expand library reference support

Add a new LinkerReference item that can be used to specify libraries that should be searched for by the linker. So, <LinkerReference Include="pthread" /> results in -lpthread being passed.

Also add a new LinkerDirectory item to specify linker search paths. <LinkerDirectory Include="foo" /> turns into -Lfoo.

Add a way to switch between Mingw-w64 and MSVC ABIs

It's generally fine to mix C++ code compiled for different ABIs as long as the code using each ABI is isolated in separate modules and those modules only talk through a C interface.

Unfortunately, things are not so simple when linking to a static library that contains C++ code. If that code is not compiled for the ABI being targeted, things break in all sorts of ways at link time. This is only really a problem on Windows where there are two major C++ ABIs: MSVC and Mingw-w64.

To enable users to link to static libraries compiled for the MSVC ABI, there needs to be a property to control the ABI on Windows. We should still default to the Mingw-w64 ABI since that's amenable to cross-compilation, but if Zig grows support for cross-compiling for the MSVC ABI one day, we will likely want to switch the default to that.

Explore static library support (for e.g. iOS)

This isn't terribly useful right now, but will become useful once the .NET SDK gains full support for Apple platforms like iOS and watchOS that only support static linking.

This will require significant work in Zig, especially for cross-compilation.

See: ziglang/zig#5145

Use `-O0` instead of `-Og` for `Debug` builds

// These exact flags are treated specially by zig cc/c++. They
// activate Debug, ReleaseFast, ReleaseSafe, and ReleaseSmall
// respectively. This in turns activates a bunch of other
// mode-specific flags that we do not have to specify here as a
// result.
builder.AppendSwitch((_configuration, _releaseMode) switch
{
(ZigConfiguration.Debug, _) => "-Og",
(ZigConfiguration.Release, ZigReleaseMode.Fast) => "-O3",
(ZigConfiguration.Release, ZigReleaseMode.Safe) => "-O2 -fsanitize=undefined",
(ZigConfiguration.Release, ZigReleaseMode.Small) => "-Oz",
_ => throw new Exception(),
});

See: ziglang/zig#11949

Add `win-arm` to the default `RuntimeIdentifiers`

This support is very incomplete in Zig right now.

But do we actually care? It doesn't seem like .NET cares too much about this RID anymore; it's only supported as a build target, not as a build host (which it used to be in the past).

Consider `clang-format` and `clang-tidy` support

In a similar vein to:

Unfortunately, Zig does not currently ship with these tools, so we would have to require users to install them.

Questions:

  • Should we mandate a specific code style like zig fmt or let it be configurable?
  • Should we try to detect the presence of these tools on disk or just go ahead and invoke them if the user asked us to?
  • Should clang-tidy be tied to WarningLevel? Or should we maybe use AnalysisLevel/AnalysisMode?

`GeneratePackageOnBuild` + fan-out build doesn't work well when referenced from other projects

Situation: Microsoft.Build.NoTargets-based project A references Zig.Sdk-based project B. Both have GeneratePackageOnBuild=true and both are RID-specific.

Issue: dotnet build -p A -r <rid> will fail with the following errors.

C:\Program Files\dotnet\sdk\6.0.100-preview.6.21355.2\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(222,5): error NU5118: File 'C:\Users\alex\source\repos\test\src\runtime\bin\Debug\linux-arm64\libcoreclr.so' is not added because the package already contains file 'runtimes\linux-arm64\native\libcoreclr.so' [C:\Users\alex\source\repos\test\src\runtime\runtime.cproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.6.21355.2\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(222,5): error NU5019: File not found: 'C:\Users\alex\source\repos\test\src\runtime\bin\Debug\linux-x64\libcoreclr.so'. [C:\Users\alex\source\repos\test\src\runtime\runtime.cproj]

`MicrosoftExtensions` should control (and disable if `true`) certain warnings

Some candidates (need to review each):

  • -Wmicrosoft-abstract (see #37)
  • -Wmicrosoft-anon-tag
  • -Wmicrosoft-charize (already controlled by -fms-extensions)
  • -Wmicrosoft-comment-paste (not supported in newer MSVC versions, and seems insane)
  • -Wmicrosoft-cpp-macro (already controlled by -fms-extensions)
  • -Wmicrosoft-enum-forward-reference (this is both a GNU and Microsoft extension, and controlled by appropriate flags)
  • -Wmicrosoft-explicit-constructor-call (limited usefulness)
  • -Wmicrosoft-fixed-enum (already controlled by -fms-extensions)
  • -Wmicrosoft-flexible-array (already controlled by -fms-extensions)
  • -Wmicrosoft-mutable-reference (I can't figure out what this even is, and it Clang doesn't seem to emit it)
  • -Wmicrosoft-sealed (unnecessary as C++11 has final)
  • -Wmicrosoft-static-assert (Clang has code for this diagnostic, but I suspect it's broken)
  • -Wmicrosoft-union-member-reference

Add a property that allows disabling specific C/C++ warnings

I don't think we can use NoWarn; it might contain various warning codes that are specific to managed tools. We would have to somehow filter those out without accidentally removing warning names recognized by Clang. Better to use a new property.

Maybe something like:

<DisableWarnings>cast-align; enum-compare; parentheses</DisableWarnings>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.