mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #975 from blockchaindev/bug/674-solc-crash
solc crashes without 'export LC_ALL=C'
This commit is contained in:
commit
b962d3c071
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <clocale>
|
||||||
#include <liblll/Compiler.h>
|
#include <liblll/Compiler.h>
|
||||||
#include <libdevcore/CommonIO.h>
|
#include <libdevcore/CommonIO.h>
|
||||||
#include <libdevcore/CommonData.h>
|
#include <libdevcore/CommonData.h>
|
||||||
@ -52,10 +53,34 @@ void version()
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
The equivalent of setlocale(LC_ALL, “C”) is called before any user code is run.
|
||||||
|
If the user has an invalid environment setting then it is possible for the call
|
||||||
|
to set locale to fail, so there are only two possible actions, the first is to
|
||||||
|
throw a runtime exception and cause the program to quit (default behaviour),
|
||||||
|
or the second is to modify the environment to something sensible (least
|
||||||
|
surprising behaviour).
|
||||||
|
|
||||||
|
The follow code produces the least surprising behaviour. It will use the user
|
||||||
|
specified default locale if it is valid, and if not then it will modify the
|
||||||
|
environment the process is running in to use a sensible default. This also means
|
||||||
|
that users do not need to install language packs for their OS.
|
||||||
|
*/
|
||||||
|
void setDefaultOrCLocale()
|
||||||
|
{
|
||||||
|
#if __unix__
|
||||||
|
if (!std::setlocale(LC_ALL, ""))
|
||||||
|
{
|
||||||
|
setenv("LC_ALL", "C", 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
enum Mode { Binary, Hex, Assembly, ParseTree, Disassemble };
|
enum Mode { Binary, Hex, Assembly, ParseTree, Disassemble };
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
setDefaultOrCLocale();
|
||||||
unsigned optimise = 1;
|
unsigned optimise = 1;
|
||||||
string infile;
|
string infile;
|
||||||
Mode mode = Hex;
|
Mode mode = Hex;
|
||||||
|
@ -98,7 +98,7 @@ case $(uname -s) in
|
|||||||
|
|
||||||
brew update
|
brew update
|
||||||
brew upgrade
|
brew upgrade
|
||||||
|
|
||||||
brew install boost
|
brew install boost
|
||||||
brew install cmake
|
brew install cmake
|
||||||
brew install jsoncpp
|
brew install jsoncpp
|
||||||
@ -127,14 +127,14 @@ case $(uname -s) in
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Linux
|
# Linux
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
Linux)
|
Linux)
|
||||||
case $(detect_linux_distro) in
|
case $(detect_linux_distro) in
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Arch Linux
|
# Arch Linux
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
Arch)
|
Arch)
|
||||||
#Arch
|
#Arch
|
||||||
echo "Installing solidity dependencies on Arch Linux."
|
echo "Installing solidity dependencies on Arch Linux."
|
||||||
@ -143,7 +143,7 @@ case $(uname -s) in
|
|||||||
# See https://wiki.archlinux.org/index.php/Official_repositories
|
# See https://wiki.archlinux.org/index.php/Official_repositories
|
||||||
sudo pacman -Sy \
|
sudo pacman -Sy \
|
||||||
base-devel \
|
base-devel \
|
||||||
boost \
|
boost \
|
||||||
cmake \
|
cmake \
|
||||||
git \
|
git \
|
||||||
;;
|
;;
|
||||||
@ -158,7 +158,7 @@ case $(uname -s) in
|
|||||||
|
|
||||||
# All our dependencies can be found in the Alpine Linux official repositories.
|
# All our dependencies can be found in the Alpine Linux official repositories.
|
||||||
# See https://pkgs.alpinelinux.org/
|
# See https://pkgs.alpinelinux.org/
|
||||||
|
|
||||||
apk update
|
apk update
|
||||||
apk add boost-dev build-base cmake jsoncpp-dev
|
apk add boost-dev build-base cmake jsoncpp-dev
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ case $(uname -s) in
|
|||||||
# Install "normal packages"
|
# Install "normal packages"
|
||||||
# See https://fedoraproject.org/wiki/Package_management_system.
|
# See https://fedoraproject.org/wiki/Package_management_system.
|
||||||
dnf install \
|
dnf install \
|
||||||
autoconf \
|
autoconf \
|
||||||
automake \
|
automake \
|
||||||
boost-devel \
|
boost-devel \
|
||||||
cmake \
|
cmake \
|
||||||
@ -326,16 +326,6 @@ case $(uname -s) in
|
|||||||
sudo apt-get -y update
|
sudo apt-get -y update
|
||||||
sudo apt-get -y install eth
|
sudo apt-get -y install eth
|
||||||
|
|
||||||
# And install the English language package and reconfigure the locales.
|
|
||||||
# We really shouldn't need to do this, and should instead force our locales to "C"
|
|
||||||
# within our application runtimes, because this issue shows up on multiple Linux distros,
|
|
||||||
# and each will need fixing in the install steps, where we should really just fix it once
|
|
||||||
# in the code.
|
|
||||||
#
|
|
||||||
# See https://github.com/ethereum/webthree-umbrella/issues/169
|
|
||||||
sudo apt-get -y install language-pack-en-base
|
|
||||||
sudo dpkg-reconfigure locales
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
@ -21,13 +21,38 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "CommandLineInterface.h"
|
#include "CommandLineInterface.h"
|
||||||
|
#include <clocale>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/exception/all.hpp>
|
#include <boost/exception/all.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
/*
|
||||||
|
The equivalent of setlocale(LC_ALL, “C”) is called before any user code is run.
|
||||||
|
If the user has an invalid environment setting then it is possible for the call
|
||||||
|
to set locale to fail, so there are only two possible actions, the first is to
|
||||||
|
throw a runtime exception and cause the program to quit (default behaviour),
|
||||||
|
or the second is to modify the environment to something sensible (least
|
||||||
|
surprising behaviour).
|
||||||
|
|
||||||
|
The follow code produces the least surprising behaviour. It will use the user
|
||||||
|
specified default locale if it is valid, and if not then it will modify the
|
||||||
|
environment the process is running in to use a sensible default. This also means
|
||||||
|
that users do not need to install language packs for their OS.
|
||||||
|
*/
|
||||||
|
void setDefaultOrCLocale()
|
||||||
|
{
|
||||||
|
#if __unix__
|
||||||
|
if (!std::setlocale(LC_ALL, ""))
|
||||||
|
{
|
||||||
|
setenv("LC_ALL", "C", 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
setDefaultOrCLocale();
|
||||||
dev::solidity::CommandLineInterface cli;
|
dev::solidity::CommandLineInterface cli;
|
||||||
if (!cli.parseArguments(argc, argv))
|
if (!cli.parseArguments(argc, argv))
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user