Opened 6 years ago

Last modified 6 years ago

#12644 new Bugs

Windows store - vcvarsall.bat is invoked with wrong arguments

Reported by: bjorn.aili@… Owned by:
Milestone: To Be Determined Component: Building Boost
Version: Boost 1.62.0 Severity: Problem
Keywords: Cc:

Description

When building a store app (ie, windows-api=store in boost), the vcvarsall.bat script (part of Visual Studio) is supposed to be invoked, for example, as

<VSPath>\VC\vcvarsall.bat x86_arm store

Boost's build system, however, invokes it without the 'store' argument, resulting in a flawed compiler environment.

This typically doesn't make a difference when building for desktop, but when building store apps for phone (arm), it can result in missing dll:s when trying to run the app consuming boost. Specifically, various boost dll:s will try to link with kernel32.lib, which does not exist on phone.

The origin of the error appears to be in boost_1_62_0/tools/build/src/tools/msvc.jam in the invocation of the maybe-rewrite-setup rule. Here, the setup-options parameter should probably contain 'store', but the <windows-api> feature is never checked to add it.

The end result is that, during boost compilation, the library include paths end up wrong and the boost binaries will link with desktop libraries instead of store libraries (eg, VCRUNTIME140D.dll instead of VCRUNTIME140D_APP.dll).

Change History (1)

comment:1 by bjorn.aili@…, 6 years ago

The following patch fixes the issue for our use case:

diff --git a/boost_1_62_0/tools/build/src/tools/msvc.jam b/boost_1_62_0/tools/build/src/tools/msvc.jam
--- a/boost_1_62_0/tools/build/src/tools/msvc.jam
+++ b/boost_1_62_0/tools/build/src/tools/msvc.jam
@@ -793,7 +793,7 @@ actions write-setup-script
 # Local helper rule to create the vcvars setup command for given architecture
 # and options.
 #
-local rule generate-setup-cmd ( version : command : parent : options * : cpu : global-setup ? : default-global-setup-options : default-setup )
+local rule generate-setup-cmd ( version : command : parent : options * : cpu : global-setup ? : default-global-setup-options + : default-setup )
 {
     local setup-prefix = "call " ;
     local setup-suffix = " >nul"$(.nl) ;
@@ -971,6 +971,9 @@ local rule configure-really ( version ? : options * )
         local setup-arm ;
         local setup-phone-i386 ;
         local setup-phone-arm ;
+        local setup-store-amd64 ;
+        local setup-store-i386 ;
+        local setup-store-arm ;
 
         if $(command)
         {
@@ -1038,6 +1041,10 @@ local rule configure-really ( version ? : options * )
             local default-global-setup-options-ia64  = x86_ia64 ;
             local default-global-setup-options-arm   = x86_arm ;
 
+            local default-global-store-setup-options-amd64 = x86_amd64 store ;
+            local default-global-store-setup-options-i386  = x86 store ;
+            local default-global-store-setup-options-arm   = x86_arm store ;
+
             # When using 64-bit Windows, and targeting 64-bit, it is possible to
             # use a native 64-bit compiler, selected by the "amd64" & "ia64"
             # parameters to vcvarsall.bat. There are two variables we can use --
@@ -1072,6 +1079,12 @@ local rule configure-really ( version ? : options * )
                 setup-$(c) = [ generate-setup-cmd $(version) : $(command) : $(parent) : $(options) : $(c) : $(global-setup) : $(default-global-setup-options-$(c)) : $(default-setup-$(c)) ] ;
             }
 
+            local store-cpu = i386 amd64 arm ;
+            for local c in $(store-cpu)
+            {
+                setup-store-$(c) = [ generate-setup-cmd $(version) : $(command) : $(parent) : $(options) : $(c) : $(global-setup) : $(default-global-store-setup-options-$(c)) : $(default-setup-$(c)) ] ;
+            }
+            
             # Windows phone has different setup scripts, located in a different directory hierarchy.
             # The 11.0 toolset can target Windows Phone 8.0 and the 12.0 toolset can target Windows Phone 8.1,
             # each of which have a different directory for their vcvars setup scripts.
@@ -1167,6 +1180,7 @@ local rule configure-really ( version ? : options * )
                 }
                 else
                 {
+                    setup-script = $(setup-store-$(c)) ;
                     toolset.flags msvc.compile .CC  <windows-api>$(api)/$(cpu-conditions) : $(setup-script)$(compiler) /Zm800 /ZW /EHsc -nologo ;
                 }
                 toolset.flags msvc.compile .ASM <windows-api>$(api)/$(cpu-conditions) : $(setup-script)$(cpu-assembler) -nologo ;
Note: See TracTickets for help on using tickets.