Opened 5 years ago

Last modified 5 years ago

#13433 new Bugs

b2 emits strange error message when building 1.66.0 on windows 10 against very new visual studio

Reported by: ivandavid14@… Owned by: Vladimir Prus
Milestone: To Be Determined Component: build
Version: Boost 1.66.0 Severity: Problem
Keywords: b2 bjam Cc:

Description

Hello, I am try to build boost against the latest version of visual studio (15.5.5, I know that 15.5.6 is out though, shouldn't be too different) and I am getting this error

failed to write command file!

when running this command

b2.exe --hash address-model=32 debug --stagedir=bin\v141\Win32\ -a --toolset=msvc-14.1 cxxflags="/D"_WIN32_WINNT=0x0600" /std:c++17 /Qspectre /D"_HAS_AUTO_PTR_ETC=1""

It has passed sometimes however it frequently doesn't. Its unclear what exactly I am doing that causes this error

Here are the things I've done step by step

1: Download boost source code and unzip it

2: run bootstrap.bat

3: run above cmd line from the visual studio developer command prompt (this has failed when using powershell too)

this was the last few things that were printed Info: Boost.Config is older than your compiler version - probably nothing bad will happen - but you may wish to look for an update Boost version. Define BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE to suppress this message. msvc.archive bin.v2\libs\date_time\build\a1668ad3e8cba9b190515cabd106a4cf\libboost_date_time-vc141-mt-gd-x32-1_66.lib common.copy bin\v141\Win32\lib\libboost_date_time-vc141-mt-gd-x32-1_66.lib bin.v2\libs\date_time\build\a1668ad3e8cba9b190515cabd106a4cf\libboost_date_time-vc141-mt-gd-x32-1_66.lib

1 file(s) copied.

compile-c-c++ bin.v2\libs\exception\build\a1668ad3e8cba9b190515cabd106a4cf\clone_current_exception_non_intrusive.obj clone_current_exception_non_intrusive.cpp Info: Boost.Config is older than your compiler version - probably nothing bad will happen - but you may wish to look for an update Boost version. Define BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE to suppress this message. failed to write command file!

I am unsure what is causing this. I don't think I am passing in parameters to the cxx flags incorrectly. I am filing a ticket because I suspect there might be a bug in b2 or bjam.

Change History (3)

comment:1 by ivandavid14@…, 5 years ago

So, I did more digging and found a file called execnt.c and modified the err_printf in prepare_command_file() to be this

err_printf("failed to write command file!\n %s\n %s\n", strerror(errno), cmdtab[ slot ].command_file->value);

and this was the output

failed to write command file! Permission denied C:\Users\divan\AppData\Local\Temp\jam2188-00-19.bat

I've ran b2 a couple of times with this and the last two digits are always 19. The contents of the bat file are always different. I change the permissions on my temp folder and that didn't fix anything.

comment:2 by Kohei Takahashi, 5 years ago

Component: Nonebuild
Owner: set to Vladimir Prus

comment:3 by ivandavid14@…, 5 years ago

Hello, after modified the execnt.c a bit more

err_printf("failed to write command file!\n %u\n %s\n",GetLastError(), cmdtab[ slot ].command_file->value);

The result of the GetLastError() was 32 which is ERROR_SHARING_VIOLATION, which has the description "The process cannot access the file because it is being used by another process."

I found that antimalware software (such as windows defender) can cause fopen to do fail. I observed that small cpp files are usually what cause the problem (like a lot of the math ones). My assumption is that they compile very quickly so the time between create a bat file, running it, then going on to the next one is very small. This creates a lot of bat files in a short amount of time, potentially triggering the antimalware software to lock the file or something like that.

I modified my command line by removing '-a' from the b2 call and I wrote a script to just keep trying to build boost and just continue from where it left off. Sorry for the rather unsatisfactory answer and I hope I didn't waste your guys time.

Note: See TracTickets for help on using tickets.